atcoder#ARC070D. [ARC070F] HonestOrUnkind
[ARC070F] HonestOrUnkind
Score : points
Problem Statement
This is an interactive task.
AtCoDeer the deer came across people. For convenience, the people are numbered through . Among them, are honest and the remaining are unkind. All of these people know who are honest and who are unkind, but AtCoDeer only knows that there are honest and unkind people. He is trying to identify all of the honest people by asking questions to these people. For one question, AtCoDeer selects and , and asks person the following question: "Is person honest?"
An honest person will always answer correctly by "Yes" or "No". An unkind person, however, will answer by selecting "Yes" or "No" arbitrarily. That is, the algorithm used by an unkind person may not be simple one such as always lying or giving random fifty-fifty answers.
AtCoDeer can ask at most questions. He will ask questions one by one, and the responses to the previous questions can be used when deciding the next question to ask.
Identify all of the honest people. If it is impossible (more formally, if, for any strategy of asking questions, there exists a strategy for unkind people to answer the questions so that there are two or more possible sets of the honest people), report that fact.
Constraints
Input and Output
First, and are given from Standard Input in the following format:
A B
If identifying the honest people is impossible, the program must immediately print the following output and terminate itself:
Impossible
Otherwise, the program shall ask questions. Each question must be written to Standard Output in the following format:
? a b
Here, and must be integers between and (inclusive). The response to the question will be given from Standard Input in the following format:
ans
Here, is either Y
or N
.
Y
represents "Yes"; N
represents "No".
Finally, the answer must be written to Standard Output in the following format:
! s_0s_1...s_{N-1}
Here, must be 1
if person is honest, and 0
if person is unkind.
Judgement
- After each output, you must flush Standard Output. Otherwise you may get
TLE
. - After you print the answer, the program must be terminated immediately. Otherwise, the behavior of the judge is undefined.
- When your output is invalid or incorrect, the behavior of the judge is undefined (it does not necessarily give
WA
).
Samples
In the following sample, , , and the answer is 101
.
Input | Output |
---|---|
In the following sample, , , and the answer is Impossible
.
Input | Output |
---|---|