#C9007. Check Full Connectivity in a Network

    ID: 53053 Type: Default 1000ms 256MiB

Check Full Connectivity in a Network

Check Full Connectivity in a Network

You are given a network of n devices numbered from 0 to n-1, and a list of m bidirectional connections between these devices. Your task is to determine whether the network is fully connected, i.e. there is a path between any two devices.

A network is considered fully connected if starting from device 0 one can reach every other device using the provided links. Formally, if we define the graph G = (V, E) where V is the set of devices and E is the set of connections, the network is fully connected if for all v \in V there exists a path from device 0 to v.

Note: When n = 1, the network is trivially fully connected.

inputFormat

The input is given via standard input (stdin) and has the following format:

n m
u1 v1
u2 v2
... 
um vm

Here, n is the number of devices, m is the number of connections, and each of the next m lines contains two integers u and v (0-indexed) representing a bidirectional connection between device u and device v.

outputFormat

Output a single line to standard output (stdout) with either yes if the network is fully connected, or no otherwise.

## sample
4 4
0 1
1 2
2 3
3 0
yes