Connectivity
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Check if the given undirected graph is connected. That is, determine whether it is possible to reach any vertex from any other vertex using the edges of the graph.
Input
The first line contains two numbers: — the number of vertices, and — the number of edges in the graph. Each of the following lines contains two numbers and , representing an edge between vertices and .
Output
Print "YES" if the graph is connected, and "NO" otherwise.
Examples
Input #1
Answer #1
Input #2
Answer #2
Submissions 14K
Acceptance rate 49%