#C2080. Network Connectivity Check
Network Connectivity Check
Network Connectivity Check
You are given a network consisting of \(N\) computers and \(M\) cables. Each cable connects two computers. The network is considered connected if there is a path between any two computers.
In other words, the network is fully connected if and only if the number of computers reachable from any starting computer is equal to \(N\). Your task is to determine whether the network is connected.
inputFormat
The input is given from standard input and has the following format:
The first line contains two integers, (N) (the number of computers) and (M) (the number of cables), separated by a space. Each of the following (M) lines contains two integers (u) and (v) indicating that there is a cable connecting computer (u) and computer (v).
Note: The computers are numbered from 1 to (N).
outputFormat
Output a single line to standard output. Print "YES" if the network is connected or "NO" otherwise.## sample
4 3
1 2
2 3
3 4
YES