Combining Rectangles#4431

Combining Rectangles

1 saniye
64 megabayt
Çok kolay

On a plane, you are given rectangles. Each rectangle has vertices at points with integer coordinates, and its sides are parallel to the coordinate axes.

Your task is to determine the total area covered by the union of these rectangles.

Giriş

The first line of the input contains the integer (0 \le N \le 1500). Each of the following lines contains four integers: x_1, y_1, x_2, y_2. These represent the coordinates of the bottom-left corner (x_1, y_1) and the top-right corner (x_2, y_2) of a rectangle (0 \le x_1 \le x_2 \le 10^9, 0 \le y_1 \le y_2 \le 10^9). Note that rectangles may degenerate into line segments or points.

Çıktı

Output a single number representing the total area of the union of the rectangles.

Örnekler

Örnek 1

Loading
Loading