#P8734. [蓝桥杯 2020 国 A] 奇偶覆盖

[蓝桥杯 2020 国 A] 奇偶覆盖

Problem Description

There are some rectangles on the plane, and both of their sides are parallel to the coordinate axes.

We say that a point is covered by a rectangle if the point lies inside the rectangle or on its boundary.

Find the areas of the regions covered by an odd number of rectangles, and covered by an even number (2)(\geq 2) of rectangles, respectively.

Input Format

The first line contains an integer nn, which denotes the number of rectangles.

The next nn lines describe the rectangles. The ii-th line contains four integers li,bi,ri,til_{i}, b_{i}, r_{i}, t_{i}, meaning that the two diagonal corners of the rectangle are (li,bi)\left(l_{i}, b_{i}\right) and (ri,ti)\left(r_{i}, t_{i}\right).

Output Format

Output two lines.

The first line contains an integer, the area of the region covered by an odd number of rectangles.

The second line contains an integer, the area of the region covered by an even number (2)(\geq 2) of rectangles.

3
1 1 3 3
2 2 4 4
3 3 5 5
8
2

Hint

For 20%20\% of the test cases, 1n101 \leq n \leq 10, 0liri1000 \leq l_{i}\le r_{i} \leq 100, 0biti1000 \leq b_{i}\le t_{i} \leq 100.

For 40%40\% of the test cases, 1n10001 \leq n \leq 1000, 0liri1000 \leq l_{i}\le r_{i} \leq 100, 0biti1000 \leq b_{i}\le t_{i} \leq 100.

For 60%60\% of the test cases, 1n100001 \leq n \leq 10000, 0liri10000 \leq l_{i}\le r_{i} \leq 1000, 0biti10000 \leq b_{i}\le t_{i} \leq 1000.

For 80%80\% of the test cases, 1n1051 \leq n \leq 10^5, 0liri1050 \leq l_{i}\le r_{i} \leq 10^5, 0biti1050 \leq b_{i}\le t_{i} \leq 10^5.

For all test cases, 1n1051 \leq n \leq 10^5, 0liri1090 \leq l_{i}\le r_{i} \leq 10^{9}, 0biti1090 \leq b_{i}\le t_{i} \leq 10^{9}.

Lanqiao Cup 2020 National Contest, Group A, Problem I.

Translated by ChatGPT 5