Codeforces Round 973 (Div. 2)
C
Password Cracking
Codeforces
1400
原题
← BD →
翻译中…

Dimash learned that Mansur wrote something very unpleasant about him to a friend, so he decided to find out his password at all costs and discover what exactly he wrote.

翻译中…

Believing in the strength of his password, Mansur stated that his password — is a binary string of length $n$. He is also ready to answer Dimash's questions of the following type:

翻译中…

Dimash says a binary string $t$, and Mansur replies whether it is true that $t$ is a substring of his password.

翻译中…

Help Dimash find out the password in no more than $2n$ operations; otherwise, Mansur will understand the trick and stop communicating with him.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 100$). The description of the test cases follows.

翻译中…

Interaction

翻译中…

At the beginning of each test case, first read $n$ ($1 \le n \le 100$) — the size of the binary string. Then proceed to guessing it.

翻译中…

To guess each string $s$, you can make no more than $2n$ queries of the following type:

翻译中…
  • "? t", where $t$ is a binary string such that ($1 \le |t| \le n$).
翻译中…

In response to this query, you will receive $1$ if $t$ is a substring of $s$, and $0$ otherwise.

翻译中…

Once you receive the answer, output a single string in the following format:

翻译中…
  • "! s", where $s$ is a binary string of size $n$.
翻译中…

After that, proceed to solve the next test case.

翻译中…

If you make an incorrect attempt or exceed the limit of $2n$ attempts, you will receive $-1$ instead of an answer and get the verdict Wrong answer. In this case, your program should terminate immediately to avoid undefined verdicts.

翻译中…

After outputting the queries, do not forget to output a newline character and flush the output buffer. Otherwise, you will receive the verdict Solution "hung". To flush the buffer, use:

翻译中…
  • fflush(stdout) or cout.flush() in C++;
  • System.out.flush() in Java;
  • flush(output) in Pascal;
  • stdout.flush() in Python;
  • refer to the documentation for other languages.
翻译中…

Hacks:

翻译中…

To use hacks, use the following format of tests:

翻译中…

The first line should contain a single integer $t$ ($1\le t\le 100$) — the number of test cases.

翻译中…

The first line of each test case should contain a single number $n$ ($1 \le n \le 100$) — the length of the string. The second line should contain a binary string of size $n$.

翻译中…

Note

翻译中…

In the first example, the string $010$ is given. Therefore, the answers to the queries are as follows:

翻译中…

"? 00" $00$ is not a substring of $010$, so the answer is $0$.

翻译中…

"? 000" $000$ is not a substring, so the answer is $0$.

翻译中…

"? 010" $010$ is a substring, so the answer is $1$.

翻译中…

In the second example, the string is $1100$, in the third $0110$, and in the fourth $10$.

翻译中…

样例

Input #1
4
3

0

0

1

4

4

2
Output #1
? 00

? 000

? 010

! 010

! 1100

! 0110

! 10
InputCopy OutputCopy
题目信息
题号
2013C
时间限制
2 s
内存限制
256 MB
标签
构造
交互题
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。