Logo
(追記) (追記ここまで)

34606번 - Minus Operator 다국어인터랙티브

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 2048 MB422100.000%

문제

The minus operator on binary values $a$ and $b$ is defined by $(a − b) = 1$ if $a = 1$ and $b = 0$; otherwise, $(a − b) = 0$. Also, the syntax of an expression is defined as follows. Here, x, parentheses, and the minus are terminal symbols, and $E$ is the start symbol.

$E ::= $x$ | (E − E)$

The judge program possesses an expression adhering to $E$. The expression is hidden from you. At the start, you are only provided with the number of terminal symbols x in the expression, denoted by $n$.

Your task is to guess the expression by making a limited number of queries.

In a single query, you specify a binary string $S$ of length $n$. The judge program then temporarily replaces each occurrence of the $i$-th terminal symbol x from the left with $S_i,ドル for $i = 1, \dots , n,ドル and evaluates the replaced expression based on the definition of the minus operator. After that, the judge program returns the evaluated value to you, which is either 0ドル$ or 1ドル$.

입력

출력

제한

인터랙션

The first line of input contains an integer $n$ (3ドル ≤ n ≤ 200$). After reading the integer, your program can start making queries. For each query, your program should write a line of the form “query $S$”. Here, $S$ is a binary string of length $n$. Each character of $S$ must be either 0 or 1. In response, an input line containing the evaluated value becomes available.

Your program can make up to 500ドル$ queries. If your program makes more than 500ドル$ queries, it will be judged as “Wrong Answer.”

When your program identifies the expression that the judge program possesses, it should write a line of the form “answer $T$”, where $T$ is the expression. After that, the interaction stops and your program should terminate.

Under the constraints above, it can be shown that the expression can be uniquely identified.

Notes on interactive judging:

  • The evaluation is non-adversarial, meaning that the expression is chosen in advance rather than in response to your queries.
  • Do not forget to flush output buffers after writing. See the “Judging Details” document for details.
  • You are provided with a command-line tool for local testing, together with input files corresponding to the sample interactions. The tool has comments at the top to explain its use.

예제 입력 1

3
0

예제 출력 1

query 111
answer ((x-x)-x)

When $n = 3,ドル there are only two possible expressions: ((x-x)-x) or (x-(x-x)). For a query $s = 111,ドル the evaluated values for these expressions are,

  • $((1 − 1) − 1) = (0 − 1) = 0,ドル and
  • $(1 − (1 − 1)) = (1 − 0) = 1$.

In this example, the judge program returns 0ドル,ドル indicating that the first expression is the correct one.

예제 입력 2

4
0
1

예제 출력 2

query 0000
query 1001
answer ((x-x)-(x-x))

노트

출처

ICPC > Regionals > Asia Pacific > Asia Pacific Championship > The 2025 ICPC Asia Pacific Championship E번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /