链接:https://ac.nowcoder.com/acm/problem/52769
来源:牛客网
题目描述
Bobo has n×mn \times mn×m points arranged into a matrix with n rows and m columns. The points in the intersection of the i-th row and the j-th column is labeled with (i, j).
He is going to perform q operations of the following 2 kinds.
1. Given parameters a, b, add edges between points (i, j) and (i, j + 1) for all a≤i≤ba \leq i \leq ba≤i≤b and 1≤j<m1 \leq j < m1≤j<m.
2. Given parameters a, b, add edges between points (i, j) and (i + 1, j) for all 1≤i<n1 \leq i < n1≤i<n and a≤j≤ba \leq j \leq ba≤j≤b.
Bobo would like to know the number of connected components after each operation.
输入描述:
The input consists of several test cases and is terminated by end-of-file. The first line of each test case contains three integers n, m and q. The i-th of the