Recently, Josh and Mike have been chatting too much on cell phones instead of studying! Their parents are upset and wish to end this chatting immediately.
So that they are not disturbed by their parents, Josh and Mike are in hiding places! Josh is located at position
Their parents have a method to find Josh and Mike. They can stand at any position
Can you help the parents find Josh and Mike by standing in no more than
Constraints
Subtask 1 [25%]
Subtask 2 [75%]
No additional constraints.
Interaction
This is an interactive problem, where the interactor is not adaptive.
First, you should read in the values of
Then, you should begin making queries. To make a query, output a line in the form ? X Y
, representing the position where the parents will stand. You should then read in an integer on the following line, which will be equal to
Finally, once you have made all of your queries, you should output a line in the form ! A B C D
, representing your guesses of Josh and Mike's coordinates. Note that the order in which the two positions are outputted does not matter, that is, you may output Josh's and Mike's coordinates in either order.
If at any point you make an invalid query, or make more than -1
on the following line. Upon reading this value, you should terminate your program to receive a Wrong Answer verdict. Otherwise, you may receive an arbitrary verdict.
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.
2 3
>>> ? 1 1
2
>>> ? 2 1
2
>>> ! 1 3 2 3
Explanation
Josh is at position
When the parents stand at
When the parents stand at
The parents have enough information to determine that Josh is at position ! 2 3 1 3
would also be a correct output, since the order in which Josh and Mike's coordinates are outputted does not matter.
Comments