时间限制:C/C++ 3秒,其他语言6秒
空间限制:C/C++ 262144K,其他语言524288K
64bit IO Format: %lld
Problem Description
There is a matrix A that has N rows and M columns. Each grid (i,j)(0 ≤ i < N, 0 ≤ j < M) is painted in white at first. Then we perform q operations: For each operation, we are given (xc, yc) and r. We will paint all grids (i, j)
that meets to black. You need to calculate the number of white grids left in matrix A.
Input
The first line of the input is T(1≤ T ≤ 40), which stands for the number of test cases you need to solve.
The first line of each case contains three integers N, M and q (1 ≤ N, M ≤ 2 x 104; 1 ≤ q ≤ 200), as mentioned above.The next q lines, each lines contains three integers xc, yc and r (0 ≤ xc < N; 0 ≤ yc < M; 0 ≤ r ≤ 105), as mentioned above.
Output
For each test case, output one number.
Sample intput
2
39 49 2
12 31 6
15 41 26
1 1 1
0 0 1
Sample Output
729
0
题意:
给定一个n×m的矩阵,在矩阵上画一些圆,求没有被圆覆盖的点的数目。
思路:
对于给的每个圆覆盖的范围,我们可以将其拆为在每一行的一段区间覆盖,那么最后对于每一行来说,我们只需要计算这一行的所有区间覆盖的范围即可。
代码:
1 | /*********************************************************************** |