When does Jennifer do math?
This is one of the world's largest unsolved problems at the moment, with dozens of world-renowned scientists struggling to find the answer to this question. You, a brilliant young researcher, have been working on this problem for the past six months. You've come up with a list of
However, one day, you find that your list has been stolen by the very Jennifer herself! You managed to strike a deal with Jennifer, and she has agreed to answer some peculiar questions about the list of numbers. In one question, you can ask her about:
- the bitwise AND of the
-th and -th numbers, or - the bitwise OR of the
-th and -th numbers
for some indices
Quirky as she is, Jennifer only permits questions on
Given these critical conditions, please write a program to recover your list of numbers!
Interaction
This is an interactive problem. The first line contains
The next
You will then begin interaction with Jennifer. If you would like to ask a question, you may output ? i & j
(followed by a \n
character) to ask the first type of question, or ? i | j
(followed by a \n
character) to ask the second type of question. For each of these questions, the pair \n
character), the answer to that question.
Otherwise, you may output !
followed by a space-separated list of \n
character), representing your guess of the list of numbers. You must terminate your program immediately after performing this operation. Note that this operation does not count towards the limit of
For all cases, it is guaranteed that all of the correct numbers in the list are integers in the range
For
If at any point you attempt an invalid question (such as invalid output format or a prohibited pair of indices), Jennifer will respond with -1
. You should terminate your program immediately after receiving this feedback, or you may receive an arbitrary verdict. If you exceed the limit of 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, Jennifer stole your list which had the numbers
5 9
1 2
1 3
1 5
2 3
2 4
2 5
3 4
3 5
4 5
>>> ? 1 & 3
0
>>> ? 2 | 5
5
>>> ? 4 | 3
5
>>> ? 1 & 2
1
>>> ? 4 | 5
5
>>> ! 3 1 4 1 5
Sample Explanation
This interaction would receive an Accepted
verdict, since it correctly guessed the list of numbers using only the permitted pairs and it did not exceed the limit of ? 1 & 4
, ? 4 | 1
, and ? 1 & 1
are not permitted since
Comments
Since the original data were weak,
test cases that are not connected graphs were added, and all submissions were rejudged.