#P9298. [POI 2020/2021 R1] Tablica binarna / 01 矩阵
[POI 2020/2021 R1] Tablica binarna / 01 矩阵
Background
This problem is translated from XXVIII Olimpiada Informatyczna – Stage I Tablica binarna.
Problem Description
Matrix has rows and columns. Rows are numbered from to from top to bottom, and columns are numbered from to from left to right. Therefore, denotes the element in row and column of the matrix. Each element of matrix is either or .
Initially, all elements in the matrix are . Then you can perform modification operations on this matrix. Each operation gives four parameters , meaning that you flip the value of every element inside the rectangle with top-left corner and bottom-right corner (changing to , or to ).
If in an operation, the top-left corner of the rectangle coincides with the top-left corner of the matrix (i.e., ), then this modification operation is called simple.
Now you want to know, after each modification operation on the matrix, what is the minimum number of simple modification operations needed to make all elements in the matrix equal to .
Input Format
The first line contains three integers , representing the number of rows, the number of columns, and the number of operations.
The next lines each contain four integers , describing one modification operation. It is guaranteed that and .
Output Format
Output lines. The -th line should contain one integer, indicating that after the -th modification, what is the minimum number of simple modification operations needed to make all elements in the matrix equal to .
2 3 3
1 2 2 2
1 1 2 1
1 2 1 3
2
1
3
4 4 16
1 1 1 1
1 2 1 2
1 3 1 3
1 4 1 4
2 1 2 1
2 2 2 2
2 3 2 3
2 4 2 4
3 1 3 1
3 2 3 2
3 3 3 3
3 4 3 4
4 1 4 1
4 2 4 2
4 3 4 3
4 4 4 4
1
1
1
1
3
3
3
1
3
3
3
1
3
3
3
1
Hint
[Sample Explanation 1]:

[Constraints]:
All testdata satisfy: , .
| Subtask ID | Constraints | Points |
|---|---|---|
| No additional constraints |
Translated by ChatGPT 5