#P12822. [NERC 2021] Interactive Treasure Hunt
[NERC 2021] Interactive Treasure Hunt
题目描述
There is a grid of cells. Two treasure chests are buried in two different cells of the grid. Your task is to find both of them. You can make two types of operations:
- : try to find the treasure in the cell . The interactor will tell you if you found the treasure or not.
- : scan from the cell . The result of this operation is the sum of Manhattan distances from the cell to the cells where the treasures are hidden. Manhattan distance from a cell to a cell is calculated as . You need to find the treasures in at most 7 operations. This includes both and operations in total. To solve the test you need to call operation at least once in both of the cells where the treasures are hidden.
Interactive Protocol
Your program has to process multiple test cases in a single run. First, the testing system writes --- the number of test cases (). Then, test cases should be processed one by one.
In each test case, your program should start by reading the integers and ().
Then, your program can make queries of two types:
-
(; ). The interactor responds with integer , if you found the treasure, and if not. If you try to find the treasure in the same cell multiple times, the result will be since the treasure is already found.
-
(; ). The interactor responds with an integer that is the sum of Manhattan distances from the cell to the cells where the treasures were hidden. The sum is calculated for both cells with treasures, even if you already found one of them.
After you found both treasures, i.e. you received for two operations, your program should continue to the next test case or exit if that test case was the last one.
输入格式
See Interactive Protocol.
输出格式
See Interactive Protocol.
1
2 3
1
1
3
0
1
SCAN 1 2
DIG 1 2
SCAN 2 2
DIG 1 1
DIG 1 3