#P17182. [ICPC 2017 Hong Kong R] Black and White
[ICPC 2017 Hong Kong R] Black and White
Problem Description
Consider a square map with cells. We indicate the coordinate of a cell by , where . Each cell has a color either white or black. The color of each cell is initialized to white. The map supports the operation $\text{flip}([x_{low}, x_{high}], [y_{low}, y_{high}])$, which flips the color of each cell in the rectangle . Given a sequence of flip operations, our problem is to count the number of black cells in the final map. We illustrate this in the following example. Figure (a) shows the initial map. Next, we call and obtain Figure (b). Then, we call and obtain Figure (c). This map contains black cells.
:::align{center}
:::
Input Format
The first line contains the number of test cases (). Each test case begins with a line containing two integers and (), where is the parameter of the map size and is the number of flip operations. Each subsequent line corresponds to a flip operation, with four integers: .
Output Format
For each test case, output the answer in a line.
1
5 2
2 4 1 3
1 5 3 5
18