0138. Windows

Имя входного файла: widows.in
Имя выходного файла: widows.out
Ограничение по времени: 1 s
Ограничение по памяти: 64 megabytes

n rectangular windows have appeared on the screen. Your task is to find the area covered simultaneously by all windows displayed.

Input file

The first line of the input file contains one integer number n (1 ≤ n ≤ 30000). The next n lines contain four integer numbers each: x1 y1 x2 y2, where (x1, y1) are coordinates of the upper-left corner of the window, and (x2, y2) are ones for the down-right. All coordinates do not exceed 5000 by an absolute value. Note that the y coordinates on the display grow downwards.

Output file

Write to the output file a single integer number – the area covered by all the windows displayed.

Examples:

widows.inwidows.out
2
0 0 3 2
1 1 4 4
2


Источник: Petrozavodsk Summer 2003. Blitz Kontest, Monday, August 25
Автор: Andrew Lopatin, Nick Durov

Обсудить       Отправить решение



Версия для печати