Andrew has a special computer that contains some very special content. He also has an appropriately special way of unlocking his computer. To get in, he needs a password of length that is a permutation of the numbers . Unfortunately, numbers can be a lot to remember. In order to help him in case he forgets, Andrew's computer returns him special hints. He can enter two integers and (, ) and his computer will tell him the bitwise AND value of and (). Andrew figures that no one would be able to guess his password given so little information and just to be extra safe, he sets his computer to only give up to hints.
Are you able to get into Andrew's computer?
Interaction
This is an interactive problem. In the first line, you will receive the integer , the length of Andrew's password.
Now, you may ask for hints from the computer. To ask for a hint, print ? i j
to ask for the bitwise AND value of and ().
The judge will respond with the answer, or -1
if your output was invalid or if you exceeded the hint limit. Exit immediately after receiving -1
or else you will receive an arbitrary verdict.
To guess the password, print ! P_1, P_2, ... P_n
and terminate your program. Note that guessing does not count as one of the hints.
Note: This interactor is not adaptive, i.e. is fixed at the start of each test case.
Subtask 1 [30%]
Subtask 2 [30%]
is less than a power of (e.g. ) and .
Subtask 3 [40%]
Sample Interaction
>>>
denotes your output; don't actually print this out.
3
>>> ? 1 2
0
>>> ? 1 3
2
>>> ? 2 3
1
>>> ! 2 1 3
Explanation for Sample Interaction
The answer is 2 1 3
. The first hint asks for . The second hint asks for . The third hint asks for .
Comments