9241: ABC292 —— D - Unicyclic Components
[Creator : ]
Description
### Problem Statement
You are given an undirected graph with $N$ vertices numbered $1$ to $N$ and $M$ edges numbered $1$ to $M$. Edge $i$ connects vertex $u_i$ and vertex $v_i$.
Determine whether every connected component in this graph satisfies the following condition.
- The connected component has the same number of vertices and edges.
You are given an undirected graph with $N$ vertices numbered $1$ to $N$ and $M$ edges numbered $1$ to $M$. Edge $i$ connects vertex $u_i$ and vertex $v_i$.
Determine whether every connected component in this graph satisfies the following condition.
- The connected component has the same number of vertices and edges.
Input
### Input
The input is given from Standard Input in the following format:
```
$N$ $M$
$u_1$ $v_1$
$\vdots$
$u_M$ $v_M$
```
The input is given from Standard Input in the following format:
```
$N$ $M$
$u_1$ $v_1$
$\vdots$
$u_M$ $v_M$
```
Output
### Output
If every connected component satisfies the condition, print `Yes`; otherwise, print `No`.
If every connected component satisfies the condition, print `Yes`; otherwise, print `No`.
Constraints
### Constraints
- $1 \leq N \leq 2 \times 10^5$
- $0 \leq M \leq 2 \times 10^5$
- $1 \leq u_i \leq v_i \leq N$
- All values in the input are integers.
- $1 \leq N \leq 2 \times 10^5$
- $0 \leq M \leq 2 \times 10^5$
- $1 \leq u_i \leq v_i \leq N$
- All values in the input are integers.
Sample 1 Input
3 3
2 3
1 1
2 3
Sample 1 Output
Yes
The graph has a connected component formed from just vertex 1, and another formed from vertices 2 and 3.
The former has one edge (edge 2), and the latter has two edges (edges 1 and 3), satisfying the condition.
The former has one edge (edge 2), and the latter has two edges (edges 1 and 3), satisfying the condition.
Sample 2 Input
5 5
1 2
2 3
3 4
3 5
1 5
Sample 2 Output
Yes
Sample 3 Input
13 16
7 9
7 11
3 8
1 13
11 11
6 11
8 13
2 11
3 3
8 12
9 11
1 11
5 13
3 12
6 9
1 10
Sample 3 Output
No