Two colors
P29033

Statement

html

Write a program that, given an undirected graph,
tells if we can paint all vertices with only two colors,
in such a way that no two neighboring vertices have the same color.

Input

Input consists of several cases,
each with the number of vertices n and the number of edges m,
followed by m pairs xy indicating an edge between x and y.
Suppose 1 ≤ n ≤ 104,
0 ≤ m ≤ 5n,
that vertices are numbered from 0 to n − 1,
x ≠ y,
and that there is no more than one edge between any pair xy.

Output

For every case,
print “yes” if the graph is two-colorable, and “no” otherwise.

About statements

The official statement of a problem is always the one
in the PDF document. The HTML and PNG versions of the statement
are also given to help you, but they may contain some content
that is not well displayed. In case of doubt, always use the PDF.