题目描述
Problem Description
In the Takahashi Kingdom, there are $ N $ cities, referred to as City $ 1 $, City $ 2 $, $\ldots$, City $ N $.
There are also $ M $ one-way roads in the Takahashi Kingdom, and the $ i $-th road allows travel from City $ u_i $ to City $ v_i $.
(Note that the roads are one-way, so it is not possible to travel from City $ v_i $ to City $ u_i $.)
Aoki, from the Aoki Kingdom, has come to the Takahashi Kingdom for a sightseeing trip. Starting from one of the $ N $ cities, Aoki will continue his trip following the steps below until he returns to the Aoki Kingdom.
- If there is a city that Aoki can reach from his current city by exactly one road, he will choose one of those cities and move to it.
- If there is no city that Aoki can reach from his current city by exactly one road, Aoki will return to the Aoki Kingdom.
Determine whether Aoki can continue his journey indefinitely without returning to the Aoki Kingdom by appropriately choosing the starting city and the destination cities during his trip.
Input Format
The input is given from the standard input in the following format:
$ N $ $ M $ $ u_1 $ $ v_1 $ $ u_2 $ $ v_2 $ $\vdots$ $ u_M $ $ v_M $
Output Format
If Aoki can continue his journey indefinitely, output Yes. Otherwise, output No.
Sample Input and Output
Sample Input #1
3 3
1 2
2 1
2 3
Sample Output #1
Yes
Sample Input #2
8 7
2 4
2 8
7 3
6 1
8 4
8 3
5 3
Sample Output #2
No
Notes/Hints
Constraints
- $1 \leq N \leq 2 \times 10^5$
- $0 \leq M \leq 2 \times 10^5$
- $1 \leq u_i, v_i \leq N$
- $u_i \neq v_i$
- $i \neq j \Rightarrow (u_i, v_i) \neq (u_j, v_j)$
- All inputs are integers.
Sample Explanation 1
Aoki can start from City $ 1 $, and repeatedly move as follows: City $1 \rightarrow$ City $2 \rightarrow$ City $1 \rightarrow$ City $2 \rightarrow$ City $1 \rightarrow \cdots$, allowing him to continue his journey indefinitely.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分