#P1599H. Hidden Fortress
Hidden Fortress
No submission language available for this problem.
Description
This is an interactive problem!
As part of your contribution in the Great Bubble War, you have been tasked with finding the newly built enemy fortress. The world you live in is a giant grid, with squares having both coordinates between and .
You know that the enemy base has the shape of a rectangle, with the sides parallel to the sides of the grid. The people of your world are extremely scared of being at the edge of the world, so you know that the base doesn't contain any of the squares on the edges of the grid (the or coordinate being or ).
To help you locate the base, you have been given a device that you can place in any square of the grid, and it will tell you the manhattan distance to the closest square of the base. The manhattan distance from square to square is calculated as . If you try to place the device inside the enemy base, you will be captured by the enemy. Because of this, you need to make sure to never place the device inside the enemy base.
Unfortunately, the device is powered by a battery and you can't recharge it. This means that you can use the device at most times.
The input contains the answers to your queries.
Interaction
Your code is allowed to place the device on any square in the grid by writing "? " . In return, it will recieve the manhattan distance to the closest square of the enemy base from square or if the square you placed the device on is inside the enemy base or outside the grid.
If you recieve instead of a positive number, exit immidiately and you will see the wrong answer verdict. Otherwise, you can get an arbitrary verdict because your solution will continue to read from a closed stream.
Your solution should use no more than queries.
Once you are sure where the enemy base is located, you should print "! " , where is the square inside the enemy base with the smallest and coordinates, and is the square inside the enemy base with the largest and coordinates. Note that answering doesn't count as one of the 40 queries.
After printing a query or printing the answer, do not forget to output end of line and flush the output. Otherwise, you will get idleness limit exceeded. To do this, use:
- fflush(stdout) or cout.flush() in C++;
- System.out.flush() in Java;
- flush(output) in Pascal;
- stdout.flush() in Python;
- See the documentation for other languages.
Input
The input contains the answers to your queries.