Alice is playing a game with Bob. She hides an array
- Define
and . - Set
and . - Tell Bob the new value of
.
Alice allows at most
Constraints
All elements of
Subtask 1 [20%]
Subtask 2 [20%]
Subtask 3 [60%]
No additional constraints.
Interaction
This is an interactive problem, where you and the judge exchange information back-and-forth to solve the problem.
At first, you should read in a line containing the integer
You will then start the interaction by proceeding with your questions. Each question should be formatted as ? i j
followed by a \n
character, with
If you believe you have the solution, you may output !
followed by a space-separated list of
Also, Alice does not like very large numbers, so all elements of the array must stay in the range
If at any point you attempt an invalid question (such as an invalid output format or a prohibited pair of indices), an element of the array goes out of the range Wrong Answer
verdict, or you may receive an arbitrary verdict. If the final list you output is incorrect, you will receive a Wrong Answer
verdict. Otherwise, you will receive a verdict of Accepted
for the corresponding test case.
Please note that you may need to flush stdout
after each operation, or interaction may halt. In C++, this can be done with fflush(stdout)
or cout << flush
(depending on whether you use printf
or cout
). In Java, this can be done with System.out.flush()
. In Python, you can use sys.stdout.flush()
.
Sample Interaction
>>>
denotes your output. Do not print this out.
In this case,
3
>>> ? 2 1
3
>>> ? 1 3
-1
>>> ? 2 3
8
>>> ! 2 5 4
Explanation
After the first question,
After the second question,
After the third question,
This interaction would receive an Accepted
verdict, since it correctly guessed the original list of numbers after asking no more than
Comments