~/algor $ cat problems/graf-ikki-guruh
Splitting into two groups
Medium
1000 ms
128 MB
51%
A class has $n$ students numbered from $1$ to $n$. $m$ pairs are known: the two students of each pair have quarrelled. The class must be split into two groups (one may be empty) so that no two quarrelling students end up in the same group. If this is possible, print YES, otherwise print NO.
Input
The first line contains two integers: $n$ and $m$. Each of the next $m$ lines contains two positive integers: $u$ and $v$ — students who have quarrelled.
Output
YES or NO.
Note
$1 \le n \le 10^{5}$
$0 \le m \le 2 * 10^{5}$
$1 \le u, v \le n$, $u \ne v$
The same pair may be given several times.
Examples
Input #1
4 4 1 2 2 3 3 4 4 1
Output #1
YES
Input #2
3 3 1 2 2 3 1 3
Output #2
NO