#P6982. [NEERC 2015] Jump

[NEERC 2015] Jump

Description

Consider a toy interactive problem ONEMAX, which is defined as follows.

You know an integer nn, and there is a hidden bit string SS of length nn. The only thing you may do is to present the system with a bit string QQ of length nn, and the system will return the number ONEMAX(Q)\text{ONEMAX}(Q), which is the number of bits that coincide in QQ and SS at the corresponding positions. The name of the ONEMAX problem comes from the fact that this problem is similar to a simpler one where S=1111S = 11\ldots11, so the problem turns into maximizing (MAX) the number of ones (ONE).

When nn is even, there is a similar (but harder) interactive problem called JUMP. The simplest way to describe JUMP is by using ONEMAX:

$$\text{JUMP}(Q)= \begin{cases} \text{ONEMAX}(Q) & \text{if } \text{ONEMAX}(Q)=n \text{ or } \text{ONEMAX}(Q)=n/2; \\ 0 & \text{otherwise.} \end{cases}$$

Basically, the only nonzero values of ONEMAX that you can see with JUMP are nn (which means you have found the hidden string SS) and n/2n/2.

Given an even integer nn, the problem size, you have to solve the JUMP problem for the hidden string SS by making interactive JUMP queries. Your task is to eventually make a query QQ such that Q=SQ = S.

Interaction Protocol

First, the judging system tells you the length of the bit string nn. Then, your solution sends queries, and the system answers them as defined by JUMP. When your solution sends a query QQ such that Q=SQ = S, the system answers nn and terminates. Therefore, if your solution tries to read or write anything after reading the answer nn, it will fail.

The limit on the number of queries is n+500n + 500. If your solution sends the (n+501)(n + 501)-th query, you will get a “Wrong Answer”. You will also get this outcome if your solution terminates too early.

If your query contains invalid characters (neither 0 nor 1), or has an incorrect length (not equal to nn), the system will stop the test and you will get a “Presentation Error”.

You may get “Time Limit Exceeded” and other errors for the usual violations.

Finally, if everything is OK (for example, your solution finds the hidden string) on every test, you will get “Accepted”. In that case, you have solved the problem.

Input Format

The first line of the input stream contains an even integer nn (2n10002 \leq n \leq 1000). The following lines of the input stream contain the answers to the corresponding queries. Each answer is an integer, either 00, n/2n/2, or nn. Each answer is on its own line.

Output Format

To make a query, print one line containing a string of length nn consisting only of the characters 0 and 1. Do not forget to print a newline and flush the output stream after printing your query.

2
1
0
1
2
01
11
10
00

Hint

Translated by ChatGPT 5