atcoder#ARC070D. [ARC070F] HonestOrUnkind

[ARC070F] HonestOrUnkind

Score : 13001300 points

Problem Statement

This is an interactive task.

AtCoDeer the deer came across NN people. For convenience, the people are numbered 00 through N1N-1. Among them, AA are honest and the remaining B(=NA)B(=N-A) are unkind. All of these NN people know who are honest and who are unkind, but AtCoDeer only knows that there are AA honest and BB unkind people. He is trying to identify all of the honest people by asking questions to these NN people. For one question, AtCoDeer selects aa and bb (0a,bN1)(0 \leq a,b \leq N-1), and asks person aa the following question: "Is person bb 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 2N2N 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 2N2N 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

  • 1A,B20001 \leq A,B \leq 2000

Input and Output

First, AA and BB 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, aa and bb must be integers between 00 and N1N-1 (inclusive). The response to the question will be given from Standard Input in the following format:

ans

Here, ansans 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, sis_i must be 1 if person ii is honest, and 0 if person ii 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, A=2A = 2, B=1B = 1, and the answer is 101.

Input Output
22 11
?? 00 11
NN
?? 00 22
YY
?? 11 00
YY
?? 22 00
YY
?? 22 22
YY
!! 101101

In the following sample, A=1A = 1, B=2B = 2, and the answer is Impossible.

Input Output
11 22
ImpossibleImpossible