题目描述
Problem Description
Snuke is trying to solve a puzzle every day for \( Q \) days.
- Each day, a grid board of \( H \) rows and \( W \) columns is streamed to Snuke's terminal. Each cell is painted either white or black. However, the board streamed on day \( i+1 \) (\( 1 \leq i \leq Q-1 \)) is the same as the board on day \( i \) with the cell at the \( r_i \)-th row and \( c_i \)-th column inverted.
- Initially, Snuke can specify a rectangular region in the board and invert the colors of all cells in that region at most once.
- After that, Snuke can invert the colors of all cells in a chosen row or column any number of times.
- The goal is to make all cells on the board the same color.
Snuke realizes that there are boards that cannot be solved. Determine for each day's board whether there is a way to make all cells the same color.
The board streamed on the first day has cells at the \( i \)-th row and \( j \)-th column (\( 1 \leq i \leq H \), \( 1 \leq j \leq W \)) painted white if \( s_{ij} \) is . and black if \( s_{ij} \) is #.
Input Format
The input is given from the standard input in the following format:
\( H \) \( W \) \( Q \) \( s_{11}s_{12}...s_{1W} \) : \( s_{H1}s_{H2}...s_{HW} \) \( r_1 \) \( c_1 \) : \( r_{Q-1} \) \( c_{Q-1} \)
Output Format
Output \( Q \) lines. The \( i \)-th line (\( 1 \leq i \leq Q \)) should contain Yes if there is a way to make all cells on the \( i \)-th day's board the same color, and No otherwise.
Sample Input and Output
Sample Input #1
3 4 4
...#
.###
.#.#
3 1
2 4
2 2
Sample Output #1
No
No
No
Yes
Sample Input #2
4 4 5
####
####
....
####
2 2
3 2
2 3
3 3
Sample Output #2
Yes
Yes
Yes
No
Yes
Notes/Hints
Constraints
- \( 1 \leq H \leq 2,000 \)
- \( 1 \leq W \leq 2,000 \)
- \( 1 \leq Q \leq 300,000 \)
- \( s_{ij} \) is either
.or# - \( 1 \leq r_i \leq H \) (\( 1 \leq i \leq Q-1 \))
- \( 1 \leq c_i \leq W \) (\( 1 \leq i \leq Q-1 \))
Sample Explanation 1
The board on the 4th day is solvable. From the board:
...#
..#.
##.#
All cells can be made white as follows:
1. Invert the rectangular region of the bottom-right 2 rows and 2 columns.
2. Invert all cells in the 3rd row.
3. Invert all cells in the 4th column.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分