#PS0000248. Diện tích giấy chồng lên nhau (Cluttered Paper)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Diện tích giấy chồng lên nhau (Cluttered Paper)
Cluttered Paper
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
There are axis-aligned rectangular sheets on a plane. Sheet has lower-left corner and upper-right corner . For every , compute the area covered by exactly sheets. Coincident sheets count separately; boundary-only intersections contribute zero area.
Input
First line: . Each of the next lines contains in that order.
Output
Print lines. Line contains the integer area covered by exactly sheets, including zero values.
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; ; all rectangles have identical coordinates.
- Subtask 3 (50 points): ; ; .
Example 1
Input
2
1 1 3 2
2 1 4 2
Output
2
1
Explanation
Each sheet has area 2 and their intersection has area 1. Exactly one sheet covers area 2.
Example 2
Input
2
1 1 3 4
3 4 6 5
Output
9
0
Explanation
The sheets touch only at a corner, with areas 6 and 3.
Example 3
Input
20
61 98 76 100
70 99 95 100
10 64 96 91
12 37 99 66
63 93 65 95
16 18 18 67
30 47 88 56
33 6 38 8
37 19 40 68
4 56 12 84
3 16 92 78
39 24 67 96
46 1 69 57
40 34 65 65
20 38 51 92
5 32 100 73
7 33 92 55
4 46 97 85
43 18 57 87
15 29 54 74
Output
1806
990
1013
1221
567
839
413
305
228
121
58
40
0
0
0
0
0
0
0
0
Explanation
Exactly one layer covers area 1806, exactly 12 layers cover area 40, and no positive area has 13 or more layers.