#P15760. [JAG 2025 Summer Camp #1] Path Flipping
[JAG 2025 Summer Camp #1] Path Flipping
题目描述
For a grid with each cell colored either white or black, let us define the beauty of the grid as follows:
- Consider performing the following operation any number of times:
- Choose a path from the upper-left corner to the lower-right corner, consisting only of downward and rightward moves. Invert the colors of all cells on the chosen path.
- The beauty of the grid is defined as the maximum possible number of cells colored black.
You have a grid with rows and columns. Initially, all cells are colored white.
You need to process queries in order. The -th query is given in the following format:
- You are given two integers and .
- If , invert the colors of all cells in the -th row from the top.
- If , invert the colors of all cells in the -th column from the left.
- Then, find the beauty of the current grid.
输入格式
The input is given in the following format:
$$\begin{aligned} & H \ W \ Q \\ & t_1 \ x_1 \\ & \vdots \\ & t_Q \ x_Q \end{aligned}$$- ()
- ()
- ()
- All input values are integers.
输出格式
Output lines. On the -th line (), output the answer for the -th query.
3 4 5
2 2
2 3
1 1
1 2
2 3
9
12
10
10
9