#P7345. 【DSOI 2021】吟唱的金色花海
【DSOI 2021】吟唱的金色花海
Description
At some moment, a golden tulip appears at some position. Then, starting from the next second, every second, each golden tulip will chant to all white tulips among the four adjacent points (up, down, left, right), turning them into golden tulips.
Now you are given a point , and the second at which it has just turned into a golden tulip since the first golden tulip appeared. You need to find the position where the very first golden tulip appeared.
Each time, you may output one line 0 x y, then the program will return a value or . means that is a white tulip at the -th second, and means that is a golden tulip at the -th second.
You may output one line 1 x y to tell the program that the position of the first golden tulip is , and thus terminate the program.
Input Format
This problem has multiple test cases.
The first line contains a positive integer , meaning there are test cases.
For each test case, the interaction starts by reading four integers , separated by single spaces. They mean that at the -th second, the tulip at has just turned golden. You can ask at most queries.
Output Format
For each test case, after you determine the answer, output one line 1 x y to end this test case, meaning you believe is where the golden tulip first appeared.
Interactive Format
During the interaction, output one line in the form 0 x y to perform one operation. Then you should read a boolean value, i.e., the return value of this operation. If , it means is a white tulip at the -th second; if , it means is a golden tulip at the -th second.
All inputs above should be read from standard input, and all outputs should be written to standard output. After outputting one line, you must flush the buffer, otherwise you may be judged as Time Limit Exceeded. Flush the buffer as follows:
- In C++, use
fflush(stdout)orcout.flush(). - In Pascal, use
flush(output). - For other languages, please check the documentation yourself.
2
1 1 0 100
0
0
1
2 1 1 10000
1
1
1
1
0 1 1
0 1 -1
0 0 1
1 0 0
0 2 0
0 0 2
0 -2 0
0 0 -2
1 0 0
Hint
| Test Point ID | |||
|---|---|---|---|
| 1 | |||
| 2~3 | |||
| 4~6 | |||
| 7~10 | |||
| 11~14 | |||
| 15~20 |
Each test point is worth points.
Note: In the worst case, asking times is guaranteed to obtain the answer. It is guaranteed that , , and the absolute values of the resulting are not greater than .
Hint: Due to the nature of interactive problems, if your algorithm is wrong, it is normal for the judge result to be TLE. Please move the mouse over the test point to see the specific error reason. Specifically:
- If your output answer is wrong, it will return You made a mistake in data i!.
- If you ask too many queries, it will return You ask too many times in data i!.
Translated by ChatGPT 5
京公网安备 11011102002149号