| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 128 MB | 96 | 48 | 23 | 34.848% |
A rectangle whose edges are parallel to the axes can always be defined by the two ends of one of its diagonals. For example, a rectangle can be drawn when the top left $(x_1, y_1)$ and the bottom right $(x_2, y_2)$ coordinates are given.
Given a set of rectangles, we are interested in finding the total area covered by them. For instance, the total area covered by the rectangles below is the area covered within the solid lines. Notice that there is no double counting for overlapping regions.
Write a program that, given a set of rectangles, computes the total area covered by all the rectangles.
The input describes a set of $N$ rectangles where $N$ ranges between 0 to 1000. On the first line is the integer $N$. The remaining lines are the coordinates of the rectangle. In each of these line, the two points $(x_1, y_1)$ and $(x_2, y_2)$ are given as 4 integers $x_1, y_1, x_2, y_2$ separated by one or more blanks. Note that they are NOT necessarily the top-left and bottom-right coordinates. In addition, $x_i$ and $y_i$ take the value between 0 to 32767ドル$.
On the first line of output, your program must write the total area covered by the rectangles. You may assume that the area is at most 32767.
4 20 5 0 15 37 26 14 9 20040 2 20050 18 17 22 33 15
715