Time Limit: | 1000ms |
Memory Limit: | 64000KiB |
Accepted: | 0 |
Submitted: | 1 |
Mars Maps
# BOI 2001 Day 2 Problem 2
# 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.
## Task
Write a program that:
- reads the description of map shapes from the input file
`mar.in`,
- computes the total area covered by the maps,
- writes the result to the output file
`mar.out`.
## Input
The input file `mar.in` 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 *x*_{1}, *y*_{1}, *x*_{2} and *y*_{2} (*0<=x*_{1}<x_{2}<=30 000, *0<=y*_{1}<y_{2}<=30 000).
The values *(x*_{1},y_{1}) and *(x*_{2},y_{2}) 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 file `mar.out` should contain one integer *A*, the total explored area (i.e.
the area of the union of all rectangles).
## Sample Input
2
10 10 20 20
15 15 25 30
## Sample Output
225
SubmitStatistics |