AtCoder Regular Contest 165
D
Substring Comparison
AtCoder
⌀ 2589
原题
← CE →
翻译中…

Problem Statement

翻译中…

For an integer sequence $X=(X_1,X_2,\dots,X_n)$, let $X[L,R]$ denote the integer sequence $(X_L,X_{L+1},\dots,X_{R})$.

翻译中…

You are given integers $N$ and $M$, and $M$ quadruples of integers $(A_i,B_i,C_i,D_i)$.

翻译中…

Determine if there is an integer sequence $X$ of length $N$ that satisfies the following condition for every $i=1,2,\dots,M$:

翻译中…
  • $X[A_i,B_i]$ is lexicographically smaller than $X[C_i,D_i]$.
翻译中…

What is lexicographical order on sequences? A sequence $S = (S_1,S_2,\ldots,S_{|S|})$ is lexicographically smaller than $T = (T_1,T_2,\ldots,T_{|T|})$ when 1. or 2. below holds. Here, $|S|$ and $|T|$ denotes the lengths of $S$ and $T$, respectively. $|S| \lt |T|$ and $(S_1,S_2,\ldots,S_{|S|}) = (T_1,T_2,\ldots,T_{|S|})$. There is an integer $1 \leq i \leq \min\lbrace |S|, |T| \rbrace$ that satisfy both of the following: $(S_1,S_2,\ldots,S_{i-1}) = (T_1,T_2,\ldots,T_{i-1})$. $S_i$ is smaller than $T_i$ (as a number).

翻译中…

Constraints

翻译中…
  • $2 \leq N \leq 2000$
  • $1 \leq M \leq 2000$
  • $1 \leq A_i \leq B_i \leq N$
  • $1 \leq C_i \leq D_i \leq N$
  • All input values are integers.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N M
A_1 B_1 C_1 D_1
A_2 B_2 C_2 D_2
\vdots
A_M B_M C_M D_M

翻译中…

Output

翻译中…

If some integer sequence satisfies the condition, print Yes; otherwise, print No.

翻译中…

样例

Input #1
4 2
1 3 3 4
4 4 1 2
Output #1
Yes
For example, $X=(1,1,2,1)$ satisfies the condition.
Input #2
3 2
1 2 2 3
2 2 1 1
Output #2
No
No integer sequence $X$ satisfies the condition.
Input #3
15 20
2 5 6 14
11 14 10 10
13 15 6 10
8 10 3 8
7 8 1 9
2 8 14 15
14 14 5 12
6 10 9 9
1 4 10 14
5 14 6 7
8 10 5 8
8 10 11 15
4 8 4 11
7 9 1 4
8 10 3 3
11 13 8 14
6 13 4 15
4 7 6 11
2 5 1 2
8 14 6 8
Output #3
No
题目信息
题号
arc165_d
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。