#P14604. [NWRRC 2025] Eight-Connected Figures
[NWRRC 2025] Eight-Connected Figures
题目背景
Looking at problems "K-Shaped Figures", "H-Shaped Figures" and "Eight-Shaped Figures" from the past three years, you might wonder what kind of geometry problem would be this year. To surprise you, this year the jury decides to change not the shape of the figure, but the "shape" itself. Today you need to find "Eight- Figures" in real time.
题目描述
An infinite square grid is hidden from you. Every cell is identified by a pair of integers and is colored either black or white with probability for each color, independently of other cells.
Two cells are considered if they share an edge or a corner. Thus, every cell has adjacent cells: , , , , , , , and .
A set of cells is called if for any two cells in , there exists a path between them using only cells from , where consecutive cells in the path are adjacent.
In one query, you can learn the color of any cell on the grid. Your task is to find an 8-connected set of cells such that all cells in the set have the same color.
You need to solve test cases. In each test case, the grid is colored randomly and independently of the other test cases.
You are allowed to make at most queries over all test cases.
输入格式
The first line contains two integers and , denoting the number of test cases and the required size of the 8-connected set (; ).
Interaction Protocol
In each test case, you can make zero or more queries to learn the colors of grid cells.
To make a query, print a line:
where are the coordinates of the requested cell (). After that, read a line containing one letter: if the cell is black, or if the cell is white.
Once you are ready to present an 8-connected set of cells of the same color, print a line:
where is a letter denoting the color of the cells in the set ( for black and for white), and are the distinct cells in the set (). The interactor does not print anything in response to this line.
After printing the set, proceed to the next test case, or terminate the program if this was the last one.
You are allowed to make at most queries over all test cases (not including the lines that print the sets). If you exceed this limit, the interactor will print instead of its usual response, and your program should terminate immediately to guarantee the Wrong Answer verdict.
The interactor is not adaptive: all random grids used in the tests have been pre-generated and remain the same across all submissions.
2 5
W
W
B
B
B
W
B
B
B
B
W
W
B
B
W
W
W
B
? 1 1
? 1 2
? 1 3
? 2 1
? 2 2
? 2 3
? 3 1
? 3 2
? 3 3
! B 2 2 1 3 3 3 2 1 3 2
? 1 1
? 1 2
? 1 3
? 2 1
? 2 2
? 2 3
? 3 1
? 3 2
? 3 3
! W 1 2 3 2 1 3 2 3 3 1
提示
In the example, the queries and the responses are separated by empty lines for clarity. In the actual interaction between your program and the interactor, there will be no empty lines.
Your solution will be evaluated on at most test files.
京公网安备 11011102002149号