Nội dung Bài tập
Mã:
MINIGAME38.4:
AREA
Tên:
Diện tích phủ hình chữ nhật
Dạng thi:
oi
Thang điểm:
10 điểm
Giới hạn thời gian:
1 giây
Giới hạn bộ nhớ:
256 MB
Được tạo bởi:
phuc

In the year 2051, several Mars expeditions have explored different areas of the red planet and produced maps of these areas. Now, the BaSA (Baltic Space Agency) has an ambitious plan: they would like to produce a map of the whole planet. In order to calculate the necessary effort, they need to know the total size of the area for which maps already exist. It is your task to write a program that calculates this area.

Task:
Write a program that: Reads the description of map shapes from the input, computes the total area covered by the maps.

Input:
The input starts with a line containing a single integer N (1<=N<=10 000), the number of available maps. Each of the following N lines describes a map. Each of these lines contains four integers x1, y1, x2 and y2  (0 <= x1 < x2 <=30000, 0<= y1 < y2 <=30000). The values (x1,y1) and (x2,y2) are the coordinates of, respectively, the bottom-left and the top-right corner of the mapped area. Each map has rectangular shape, and its sides are parallel to the x- and y-axis of the coordinate system.

Output:

The output contain one integer A, the total explored area (i.e. the area of the union of all rectangles).

Example

InputOutput
2
10 10 20 20
15 15 25 30
225


Trên mặt phẳng toạ độ người ta vẽ ra N hình chữ nhật . Hãy tính diện tích che phủ bởi N hình chữ nhật này , biết rằng N hình chữ nhật này song song với 2 trục Ox và Oy .

Input

Dòng 1 : số nguyên N ( 1 ≤ N ≤ 10000 ) .

N dòng tiếp theo , mỗi dòng gồm 4 số nguyên x1 , y1 , x2 , y2 tương ứng là toạ độ góc trái dưới và góc phải trên của hình chữ nhật thứ i.( 0 ≤ x1 ≤ x2 ≤ 30000 , 0 ≤ y1≤ y2 ≤ 30000 ) .

Output

Gồm 1 dòng ghi ra diện tích phủ bởi N hình chữ nhật


Ví dụ:

InputOutput
2
10 10 20 20
15 15 25 30
225



    Quảng cáo
       Ngôn ngữ : 

       Theme : 
Mời bạn soạn code



		



      Ai có thể xem bài này : 

Thông tin



Phần thảo luận