Task DescriptionDiscussion (0)
Task :: BOI-Mars Maps
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.
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 ≤ 30 000 , 0 ≤ y1 < y2 ≤ 30 000 ). 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.
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 ≤ 30 000 , 0 ≤ y1 < y2 ≤ 30 000 ). 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 should contain one integer A, the total area of the explored territory (i.e. the area of the union of all the rectangles.
The output should contain one integer A, the total area of the explored territory (i.e. the area of the union of all the rectangles.
Input:
Output:
2
10 10 20 20
15 15 25 30
10 10 20 20
15 15 25 30
Output:
225
Submit Solution
Available Languages
Task info
Task Ratings
| Difficulty: | 4.2 (5 votes) |
| Quality: | 3.4 (5 votes) |
Acceptance Rate
Recent Submissions
Fastest Solutions
| User | Time |
|---|---|
| halil | 0.09 s. |
| jzivkovic | 0.105 s. |
| ohhenrie | 0.12 s. |
| Semzm33 | 0.12 s. |
| Lazar_94_kg | 0.12 s. |
| _qwAker_ | 0.135 s. |
| msantl | 0.135 s. |
| Daniel93 | 0.135 s. |
| veljkovranic | 0.135 s. |
| A.Armin | 0.135 s. |
Solved By
crusader, _qwAker_, 1010011010, msantl, smiljo, flashmt, pasin30055, tamaki, demjan0001, Daniel93, halil, ohhenrie, smiljko, ddakev, Semzm33
Home
Training
Competitions
Forum
FAQ