#C3426. Ascending Path Hiking

    ID: 46852 Type: Default 1000ms 256MiB

Ascending Path Hiking

Ascending Path Hiking

In this problem, you are given an undirected graph representing a network of checkpoints labeled from 1 to (N). The checkpoint 1 is the base camp and checkpoint (N) is the summit. You are allowed to hike only on an ascending path, which means you can only move from a checkpoint with a lower number to a checkpoint with a higher number. Moreover, you must visit all (N) checkpoints exactly once. Effectively, you need to determine whether there exists an ascending path from 1 to (N) that visits each checkpoint exactly once. Note that, due to the ascending constraint, the only possible sequence is (1, 2, \ldots, N). Thus, the task reduces to verifying if for every (i) (where (1 \leq i < N)) there exists an edge between checkpoint (i) and checkpoint (i+1).

inputFormat

The first line of input contains two integers (N) and (M) where (N) is the number of checkpoints and (M) is the number of undirected paths. The next (M) lines each contain two integers (a) and (b) indicating that there is a path between checkpoint (a) and checkpoint (b).

outputFormat

Output a single line containing either "Yes" if there exists an ascending hiking path that visits every checkpoint exactly once, or "No" otherwise.## sample

4 4
1 2
2 3
3 4
1 3
Yes