#P3820. 小D的地下温泉
小D的地下温泉
Description
At the beginning, he will tell you the current state of this land, but Xiao D has some pretend operations and wants you to perform them for him:
-
Xiao D specifies positions and wants to know which of these positions has the largest soaking range if he goes down to soak at that position. The soaking range is defined as the number of positions reachable from the specified position by moving in the four directions up, down, left, and right. If the queried position is soil, then the range is . If multiple positions tie for the maximum, output the one that appears earlier in the given order. The positions are indexed as .
-
Xiao D specifies positions. He will use magic to toggle the terrain of these places in order. That is, if the original position is soil, it becomes a hot spring; if the original position is a hot spring, it becomes soil. Because Xiao D does not want the activity range to shrink too quickly, when turning a hot spring into soil he will not split a connected region.
Input Format
The first line contains two integers, , representing the size of the land.
The next lines each contain characters, either . (representing a hot spring) or * (representing soil).
The -th line contains an integer , the number of operations.
In each of the next lines, first read two integers and , representing the operation type and the number of specified points. On the same line, there are also numbers , which represent the operation positions $(x_{1}, y_{1}), (x_{2}, y_{2}), \ldots, (x_{w}, y_{w})$.
Output Format
For each operation of type , output the answer to the query on a new line.
5 5
.*...
.****
*....
*****
.....
3
1 2 1 1 1 3
2 1 3 1
1 2 1 1 1 3
2
1
Hint
- For of the testdata, .
- For of the testdata, .
- Constraints: for of the testdata, .
- The testdata is generated on Windows.
Translated by ChatGPT 5
京公网安备 11011102002149号