/
Time Limit: 2 sec / Memory Limit: 1024 MiB
問題文
1 から N の番号がついた N 人の人がいます。
「人 A_i は人 B_i より背が高い」という情報が M 個与えられるので、矛盾がないかどうか確かめてください。
制約
- 2 \leq N \leq 100
- 0 \leq M \leq 100
- 1 \leq A_i,B_i \leq N
- A_i \neq B_i
- 入力に含まれる値は全て整数である
入力
入力は以下の形式で標準入力から与えられる。
N M A_1 B_1 \vdots A_M B_M
出力
与えられる情報に矛盾がないならば Yes、矛盾があるならば No と出力せよ。
入力例 1
3 3 1 2 2 3 3 1
出力例 1
No
「人 1 は人 2 より背が高い」「人 2 は人 3 より背が高い」「人 3 は人 1 より背が高い」の 3 つ全てが同時に成立することはありません。
入力例 2
4 9 1 3 1 3 1 3 1 3 2 4 1 4 3 4 2 3 1 2
出力例 2
Yes
同じ情報が複数回与えられることもあります。
入力例 3
3 3 1 2 2 1 1 3
出力例 3
No
入力例 4
100 0
出力例 4
Yes
Problem Statement
There are N people numbered 1 to N.
You are given N pieces of information, each in this form: person A_i is taller than person B_i. Determine whether they are consistent.
Constraints
- 2 \leq N \leq 100
- 0 \leq M \leq 100
- 1 \leq A_i,B_i \leq N
- A_i \neq B_i
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
N M A_1 B_1 \vdots A_M B_M
Output
If the given pieces of information are consistent, print Yes; otherwise, print No.
Sample Input 1
3 3 1 2 2 3 3 1
Sample Output 1
No
It does not hold simultaneously that person 1 is taller than person 2, person 2 is taller than person 3, and person 3 is taller than person 1.
Sample Input 2
4 9 1 3 1 3 1 3 1 3 2 4 1 4 3 4 2 3 1 2
Sample Output 2
Yes
The same piece of information may be given multiple times.
Sample Input 3
3 3 1 2 2 1 1 3
Sample Output 3
No
Sample Input 4
100 0
Sample Output 4
Yes