#abc287c. [abc287_c]Path Graph?
[abc287_c]Path Graph?
Problem Statement
You are given a simple undirected graph with vertices and edges. The vertices are numbered , and the edges are numbered .
Edge connects vertices and .
Determine if this graph is a path graph.
What is a simple undirected graph? A simple undirected graph is a graph without self-loops or multiple edges whose edges do not have a direction.
What is a path graph? A graph with vertices numbered is said to be a path graph if and only if there is a sequence that is a permutation of and satisfies the following conditions:
- For all , there is an edge connecting vertices and .
- If integers and satisfies and , then there is no edge that connects vertices and .
Constraints
- All values in the input are integers.
- The graph given in the input is simple.
Input
The input is given from Standard Input in the following format:
Output
Print Yes
if the given graph is a path graph; print No
otherwise.
Sample Input 1
4 3
1 3
4 2
3 2
Sample Output 1
Yes
Illustrated below is the given graph, which is a path graph.
Sample Input 2
2 0
Sample Output 2
No
Illustrated below is the given graph, which is not a path graph.
Sample Input 3
5 5
1 2
2 3
3 4
4 5
5 1
Sample Output 3
No
Illustrated below is the given graph, which is not a path graph.