PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CC0000080. Diện tích hợp các hình chữ nhật II (Rectangle Area II)
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 các hình chữ nhật II (Rectangle Area II)
Rectangle Area II
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
Given axis-aligned rectangles with bottom-left corner and top-right corner , compute their union area, counting overlapping regions only once. Return the answer modulo .
Input
The first line contains , followed by lines . This is the stdin/stdout adaptation.
Output
Print the union area modulo .
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; ; .
Examples
Input
3
0 0 2 2
1 0 2 3
1 0 3 1
Output
6
Explanation
The first rectangle covers area . The second adds area above it, and the third adds area to its right. The union area is .