Baltic OI '01 P5 - Mars Maps

View as PDF

Submit solution


Points: 15 (partial)
Time limit: 1.0s
Memory limit: 256M

Problem type
Baltic Olympiad in Informatics: 2001 Day 2, Problem 2

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.

Constraints

1 \le N \le 10^4

0 \le x_1 < x_2 \le 3 \times 10^4

0 \le y_1 < y_2 \le 3 \times 10^4

Input Specification

The input starts with a line containing a single integer N, 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. 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 Specification

The output 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

Sample Explanation

The area of the rectangle union above is 225 units squared.


Comments

There are no comments at the moment.