atcoder#ARC078C. [ARC078E] Awkward Response
[ARC078E] Awkward Response
Score : points
Problem Statement
This is an interactive task.
Snuke has a favorite positive integer, . You can ask him the following type of question at most times: "Is your favorite integer?" Identify .
Snuke is twisted, and when asked "Is your favorite integer?", he answers "Yes" if one of the two conditions below is satisfied, and answers "No" otherwise:
- Both and hold.
- Both and hold.
Here, is the decimal representation of (without leading zeros) as a string. For example, 123
and = 2000
.
Strings are compared lexicographically. For example, 11111
123
and 123456789
9
.
Constraints
Input and Output
Write your question to Standard Output in the following format:
? n
Here, must be an integer between and (inclusive).
Then, the response to the question shall be given from Standard Input in the following format:
ans
Here, is either Y
or N
. Y
represents "Yes"; N
represents "No".
Finally, write your answer in the following format:
! n
Here, must hold.
Judging
- 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
).
Sample
Below is a sample communication for the case :
Input | Output |
---|---|
? 1 |
|
Y |
|
? 32 |
|
N |
|
? 1010 |
|
N |
|
? 999 |
|
Y |
|
! 123 |
- Since and , the first response is "Yes".
- Since but , the second response is "No".
- Since but , the third response is "No".
- Since and , the fourth response is "Yes".
- The program successfully identifies in four questions, and thus passes the case.