OI Problems   关于

#46wh08. New Year and Conference

时间限制:2 s       空间限制:1 GiB       标签: CodeForces 缺题解 

算法难度等级:0       思维难度等级:0       实现难度等级:0


本题来源于:Hello 2020 Problem D

  • 简体中文
  • English

题目描述

充满快乐的,Hyunuk 将要举办一个关于将来的一年有多伟大的大会!

大会有 nn 个讲座。Hyunuk 有两个可供选择的会场 A 和 B。对于 nn 个讲座中的每一个,演讲者选择了两个时间区间 [sai,eai][sa_{i},ea_{i}]saieaisa_{i} \leq ea_{i})和 [sbi,ebi][sb_{i},eb_{i}]sbiebisb_{i} \leq eb_{i})。如果大会在 A 会场举办,那么讲座就会在 saisa_{i}eaiea_{i} 的时间举行;如果大会在 B 会场举行,那么该讲座就会在 sbisb_{i}ebieb_{i} 的时间举行。Hyunuk 只能选定两个会场中的一个,然后所有讲座都要在那个会场举行。

两个讲座被称为冲突,当且仅当它们共用了同一个时间点。正式地,我们称一个在区间 [x,y][x,y] 中举办的讲座和一个在 [u,v][u,v] 区间举办的讲座冲突,当且仅当 max(x,u)min(y,v)\max(x,u) \leq \min(y,v)

我们称一个听众可以参加所有讲座的一个子集 ss,当且仅当这个子集中任何一对讲座都不冲突。注意:是否能参加这个子集 ss 的可能取决于 Hyunuk 选择的是 A 会场或是 B 会场来举办大会。

对于一个子集 ss,若在一个会场,观众可以参加,而在另一个会场,观众却不可以参加,那么它被称为“会场敏感的”。

对于观众来说,是否存在一个会场敏感的子集 ss 是一个重要的问题,因为观众无法确定讲座时间是否会冲突。Hyunuk 会开心当且仅当不存在任意一个会场敏感的子集。请判断 Hyunuk 是否会开心。

输入格式

第一行包含一个整数 nn,表示讲座的数目;

接下来的 nn 行,每行四个整数 sai, eai, sbi, ebisa_{i},\ ea_{i},\ sb_{i},\ eb_{i}1sai, eai, sbi, ebi1091 \leq sa_{i},\ ea_{i},\ sb_{i},\ eb_{i} \leq 10^9saieaisa_{i} \leq ea_{i}sbiebisb_{i} \leq eb_{i})。

输出格式

当 Hyunuk 开心时,输出 YES,否则输出 NO

2
1 2 3 6
3 4 7 8
YES
3
1 3 2 4
4 5 6 7
3 4 5 5
NO
6
1 5 2 9
2 4 5 8
3 6 7 11
7 10 12 16
8 11 13 17
9 12 14 18
YES

Filled with optimism, Hyunuk will host a conference about how great this new year will be!

The conference will have nn lectures. Hyunuk has two candidate venues aa and bb . For each of the nn lectures, the speaker specified two time intervals [sai,eai][sa_i, ea_i] ( saieaisa_i \le ea_i ) and [sbi,ebi][sb_i, eb_i] ( sbiebisb_i \le eb_i ). If the conference is situated in venue aa , the lecture will be held from saisa_i to eaiea_i , and if the conference is situated in venue bb , the lecture will be held from sbisb_i to ebieb_i . Hyunuk will choose one of these venues and all lectures will be held at that venue.

Two lectures are said to overlap if they share any point in time in common. Formally, a lecture held in interval [x,y][x, y] overlaps with a lecture held in interval [u,v][u, v] if and only if max(x,u)min(y,v)\max(x, u) \le \min(y, v) .

We say that a participant can attend a subset ss of the lectures if the lectures in ss do not pairwise overlap (i.e. no two lectures overlap). Note that the possibility of attending may depend on whether Hyunuk selected venue aa or venue bb to hold the conference.

A subset of lectures ss is said to be venue-sensitive if, for one of the venues, the participant can attend ss , but for the other venue, the participant cannot attend ss .

A venue-sensitive set is problematic for a participant who is interested in attending the lectures in ss because the participant cannot be sure whether the lecture times will overlap. Hyunuk will be happy if and only if there are no venue-sensitive sets. Determine whether Hyunuk will be happy.

Input

The first line contains an integer nn ( 1n1000001 \le n \le 100\,000 ), the number of lectures held in the conference.

Each of the next nn lines contains four integers saisa_i , eaiea_i , sbisb_i , ebieb_i ( 1sai,eai,sbi,ebi1091 \le sa_i, ea_i, sb_i, eb_i \le 10^9 , saieai,sbiebisa_i \le ea_i, sb_i \le eb_i ).

Output

Print "YES" if Hyunuk will be happy. Print "NO" otherwise.

You can print each letter in any case (upper or lower).

2
1 2 3 6
3 4 7 8
YES
3
1 3 2 4
4 5 6 7
3 4 5 5
NO
6
1 5 2 9
2 4 5 8
3 6 7 11
7 10 12 16
8 11 13 17
9 12 14 18
YES

Note

In second example, lecture set {1,3}\{1, 3\} is venue-sensitive. Because participant can't attend this lectures in venue aa , but can attend in venue bb .

In first and third example, venue-sensitive set does not exist.