You are going to the farmers market to buy and sell fruit. There are
You want to try and figure out the prices of each of the
Unfortunately, Beautiful_Times has poor memory and he will only remember one value: whether there were more markets where you made a profit of strictly greater than
On some days, instead of asking Beautiful_Times to go to all markets, you will ask him to compare the results of certain previous days. You will choose two days
- Considering only the markets where you earned a profit of at least
on day , and a profit of at least on day , choose two of the markets uniformly at random and output the price of the banana. If there is only one market, Beautiful_Times will output-1
for the second value. If there are no such markets, he will output-1
twice.
However, Beautiful_Times does not allow you to choose any two days. He will only allow you to compare day
Can you use this information to determine the prices of each of the
There will be
Interaction
The first line for each case will be the integer
Next, you must start interaction with Beautiful_Times.
Output ? A_b A_s B_b B_s P_j
to ask Beautiful_Times to buy 1
. If there were fewer markets, you will receive the integer -1
. If they are equal, you will receive the integer 0
.
Output C j k
to compare day x_1 x_2
, the prices of the banana at two markets chosen uniformly at random from the markets where you earned a profit of at least -1
for the second value. If there are no such markets, he will output -1
twice.
When you have determined the prices of each market, output !
. This should be followed by a_i b_i
, meaning the
You must then continue onto the next case. The interactor will not output anything to indicate the end of this case, or whether your answer is correct or not.
If at any point, you receive a -400
, this means Beautiful_Times could not parse your question/answer or the question was invalid, and you must exit your program immediately to ensure you receive WA
. Otherwise, your verdict could be undefined.
REMINDER: After each output, remember to flush. 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()
.
Note: The interactor may use up to 1 second of the time limit.
Constraints
For all subtasks:
The number of markets will be between
You must determine each market's prices in at most
Subtask 1 [5%]
Subtask 2 [10%]
Subtask 3 [10%]
Subtask 4 [25%]
Subtask 5 [50%]
No additional constraints.
Sample Interaction
Please note that the sample input does not satisfy all of the constraints for some of the subtasks. It will not appear in any of the test cases.
In this sample,
There is
Market
There are
Market
Market
Market
>>>
denotes your output. Do not print this out.
1
>>> ? 6 3 4 9 30
-1
>>> !
>>> 3 7
3
>>> ? 1 2 5 3 -3
0
>>> ? 1 4 2 9 26
1
>>> C 1 2
4 -1
>>> !
>>> 5 4
>>> 2 3
>>> 6 1
Sample Explanation
In the first test case, Beautiful_Times collects a profit of -1
. An answer is then printed. Although it is incorrect, the judge will continue on with the next test cases.
In the second test case, Beautiful_Times collects profits of 0
. On day 1
. On day 0
. Since market 4 -1
. Finally, the correct answer is printed. Beautiful_Times will not respond after the last test case. Note that the markets may be printed in any order.
Sample Interactor
You are given two Python scripts to test your solution locally. You must have Python 3 installed in order to run the files. Please notes that the sample interactor may behave differently than the actual interactor.
There are 2 files: interactive_runner.py
and interactor.py
. To use the interactor, run the following command:
python3 interactive_runner.py python3 interactor.py SUBTASK_NUMBER -- CMD_LINE_SOLUTION
SUBTASK_NUMBER
is an integer between
CMD_LINE_SOLUTION
is the command required to run the solution. In C and C++, the command is ./binary_executable_name
. In Java, the command is java class_name
. In Python 3, the command is python3 file_name.py
.
The interactor will run
Comments