Area of Overlapping Rectangles
Print the total area covered by the union of N axis-aligned rectangles (overlaps counted once).
Input: the first line has N; each of the next N lines has x1 y1 x2 y2 (lower-left and upper-right corners).
Output: the area of the union.
Constraints:
- 1 ≤ N ≤ 103
- |coordinates| ≤ 104
Sample Tests
Input 1
2 0 0 2 2 1 1 3 3
Output 1
7
Input 2
1 0 0 5 5
Output 2
25
Discussion (opens after you solve — no spoilers before)
No comments yet.