PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CC0000082. Ghép kín thành một hình chữ nhật (Perfect Rectangle)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Ghép kín thành một hình chữ nhật (Perfect Rectangle)
Perfect Rectangle
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
Given axis-aligned rectangles, determine whether they form an exact rectangular cover: there must be neither any uncovered holes nor any positive-area overlaps.
Input
The first line contains , followed by lines . This is the stdin/stdout adaptation.
Output
Print YES if the rectangles form a perfect rectangular cover, otherwise NO.
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; ; .
Examples
Input
5
1 1 3 3
3 1 4 2
3 2 4 4
1 3 2 4
2 3 3 4
Output
YES
Explanation
The five rectangles fill the bounding box from to exactly, with area and no gaps or overlaps.