eolymp
bolt
Try our new interface for solving problems
Problems

Connectivity

Connectivity

Check whether the given undirected graph is connected. That its possible to go from any vertex to any other along the edges of this graph. \InputFile The first line contains the number $n$ of vertices and the number $m$\ of edges in the graph $(1 \le n \le 100, 1 \le m \le 10000)$. The following $m$ lines contain two numbers $u_i$ and $v_i$ by a space $(1 \le u_i, v_i \le n)$; each such line means that the graph there is an edge between vertices $u_i$ and $v_i$. \OutputFile Print \textbf{"YES"}, if the graph is connected, and \textbf{"NO"} otherwise. \includegraphics{https://static.e-olymp.com/content/8e/8ef8ceebd71bfb5ba0f9b8bc45eb9e38fdf41f30.gif}
Time limit 1 second
Memory limit 128 MiB
Input example #1
3 2
1 2
3 2
Output example #1
YES
Input example #2
3 1
1 3
Output example #2
NO