PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CC0000081. Diện tích hợp hình chữ nhật (Area of Rectangles)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Diện tích hợp hình chữ nhật (Area of Rectangles)
Area of Rectangles
Source: CSES
Version: Phuoc Hung OJ Extended
Problem Statement
Given axis-aligned rectangles, compute the exact union area of the regions covered by at least one rectangle. Overlaps must be counted once. Print the exact value without any modulo.
Input
The first line contains , followed by lines .
Output
Print the exact union area as an integer.
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; ; .
Examples
Input
3
1 3 4 5
3 1 7 4
5 3 8 6
Output
24
Explanation
The rectangle areas are , , and . Two overlap regions have areas and , and there is no triple overlap. Hence .