An artisan paints a mural using $$$n$$$ axis-aligned rectangular stencils. Rectangle $$$i$$$ is the half-open set $$$[x_{1,i},x_{2,i}) \times [y_{1,i},y_{2,i})$$$. Rectangles may overlap, share boundary segments, or coincide.
A point is covered exactly once if it belongs to exactly one rectangle. The union consists of all points covered by at least one rectangle. Its perimeter is the total length of the boundary separating covered points from uncovered points; shared boundaries inside the union do not contribute.
Find (1) the area covered exactly once and (2) the perimeter of the union.
The first line contains an integer $$$n$$$ ($$$1 \le n \le 200000$$$).
Each of the next $$$n$$$ lines contains four integers $$$x_1$$$, $$$y_1$$$, $$$x_2$$$, and $$$y_2$$$ describing one rectangle ($$$-10^9 \le x_1 \lt x_2 \le 10^9$$$ and $$$-10^9 \le y_1 \lt y_2 \le 10^9$$$).
Print two integers: the total area covered by exactly one rectangle and the perimeter of the union, in that order.
Both values fit in a signed 64-bit integer but may exceed the signed 32-bit range.
20 0 2 21 0 3 1
4 10
Rectangles are half-open only to make point membership unambiguous. Changing which rectangle owns a shared boundary does not change either requested value. Use 64-bit integer arithmetic.
| Название |
|---|


