| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 14 | 3 | 3 | 27.273% |
There is an $n$ by $m$ chessboard with $n \times m$ squares in total. Rows and columns are numbered starting from 1ドル,ドル and the coordinates of the square in the $i$-th column and $j$-th row are denoted as $(i, j)$. Initially, all squares are white. Now, you need to perform $q$ coloring operations on this chessboard.
There are three types of coloring operations:
Now you want to know how many black squares there are on the chessboard after performing $q$ coloring operations.
The first line of input contains an integer $c,ドル which represents the test case number. If $c = 0,ドル it means that this test case is a sample test.
The second line of input contains three positive integers $n,ドル $m,ドル and $q,ドル which respectively represent the number of columns, rows, and the number of coloring operations on the chessboard.
Then $q$ lines follow, each line containing five positive integers $t, x_1, y_1, x_2, y_2$. Among them, $t = 1$ represents the first type of coloring operation, $t = 2$ represents the second type of coloring operation, and $t = 3$ represents the third type of coloring operation. $x_1, y_1, x_2, y_2$ represent the four parameters of the coloring operation.
Output a line containing an integer, representing the number of black squares on the chessboard that have been colored.
For all test data, it is guaranteed that: 1ドル \leq n, m \leq 10^9, 1 \leq q \leq 10^5, 1 \leq x_1, x_2 \leq n, 1 \leq y_1, y_2 \leq m,ドル and there are at most 5ドル$ operations of the third type.
0 5 5 3 1 1 3 5 3 2 3 1 3 5 3 1 1 5 5
13
In this sample test, we performed a total of three coloring operations, as shown in the following figure. The state of the chessboard after each of the three operations are given in the order from left to right.
After the first operation, squares $(1, 3),ドル $(2, 3),ドル $(3, 3),ドル $(4, 3),ドル $(5, 3)$ are colored black.
After the second operation, squares $(3, 1),ドル $(3, 2),ドル $(3, 3),ドル $(3, 4),ドル $(3, 5)$ are colored black.
After the third operation, $(1, 1),ドル $(2, 2),ドル $(3, 3),ドル $(4, 4),ドル $(5, 5)$ are colored black.
After all three coloring operations, a total of 13ドル$ squares are colored black.
samples.zip