本题来源于:Hello 2020 Problem D
充满快乐的,Hyunuk 将要举办一个关于将来的一年有多伟大的大会!
大会有 个讲座。Hyunuk 有两个可供选择的会场 A 和 B。对于 个讲座中的每一个,演讲者选择了两个时间区间 ()和 ()。如果大会在 A 会场举办,那么讲座就会在 到 的时间举行;如果大会在 B 会场举行,那么该讲座就会在 到 的时间举行。Hyunuk 只能选定两个会场中的一个,然后所有讲座都要在那个会场举行。
两个讲座被称为冲突,当且仅当它们共用了同一个时间点。正式地,我们称一个在区间 中举办的讲座和一个在 区间举办的讲座冲突,当且仅当 。
我们称一个听众可以参加所有讲座的一个子集 ,当且仅当这个子集中任何一对讲座都不冲突。注意:是否能参加这个子集 的可能取决于 Hyunuk 选择的是 A 会场或是 B 会场来举办大会。
对于一个子集 ,若在一个会场,观众可以参加,而在另一个会场,观众却不可以参加,那么它被称为“会场敏感的”。
对于观众来说,是否存在一个会场敏感的子集 是一个重要的问题,因为观众无法确定讲座时间是否会冲突。Hyunuk 会开心当且仅当不存在任意一个会场敏感的子集。请判断 Hyunuk 是否会开心。
第一行包含一个整数 ,表示讲座的数目;
接下来的 行,每行四个整数 (,,)。
当 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 lectures. Hyunuk has two candidate venues and . For each of the lectures, the speaker specified two time intervals ( ) and ( ). If the conference is situated in venue , the lecture will be held from to , and if the conference is situated in venue , the lecture will be held from to . 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 overlaps with a lecture held in interval if and only if .
We say that a participant can attend a subset of the lectures if the lectures in do not pairwise overlap (i.e. no two lectures overlap). Note that the possibility of attending may depend on whether Hyunuk selected venue or venue to hold the conference.
A subset of lectures is said to be venue-sensitive if, for one of the venues, the participant can attend , but for the other venue, the participant cannot attend .
A venue-sensitive set is problematic for a participant who is interested in attending the lectures in 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.
The first line contains an integer ( ), the number of lectures held in the conference.
Each of the next lines contains four integers , , , ( , ).
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
In second example, lecture set is venue-sensitive. Because participant can't attend this lectures in venue , but can attend in venue .
In first and third example, venue-sensitive set does not exist.