Mike has gotten so bored of playing Factor Solitaire that he vows to never play it again! Instead, he has developed an interest in a new game which he calls Factor Klondike.
Josh has a permutation of the first
Can you help Mike to win as efficiently as possible? You can make at most
Constraints
Scoring
Let
Score | |
---|---|
If your program fails to guess the permutation in any test case, then you will receive
Interaction
This is an interactive problem. Note that the interactor is not adaptive, and the target permutation
At first, you should read in a single integer on a single line, representing the value of
Then, you will have the opportunity to make up to ? l r x
. Then, you should read in a single integer on a single line. This integer will be
Finally, once you have made all of your queries, you should output a line in the form ! p_1 p_2 ... p_N
, where
If at any point you format your queries incorrectly, or ask more than
If you successfully guess the correct sequence, then you will receive an Accepted verdict for that test case. Your final score for the problem will be determined through the aforementioned scoring mechanism. You will be told the number of queries that you used.
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.
4
>>> ? 1 2 2
1
>>> ? 3 4 2
0
>>> ? 1 3 3
1
>> ! 4 2 3 1
Explanation
Josh's permutation is
For the first query, both
For the second query, neither
For the third query,
The permutation has been correctly guessed, and the score for this test case would be
Comments