1361 No way to regret
Description
Last year, AngryHair made a serious mistake during the contest in Jilin. There was a simple problem which could be solved by matching. But the programmer didn’t realize that our template can only be used for Bipartite matching problem, and the graph constructed by the programmer is not a Bipartite Graph, which lead to WA. After that, AngryHair decided to write a program to judge whether a graph is a bipartite one. A bipartite graph, also called a bigraph, is a set of graph vertices decomposed into two disjoint sets such that no two vertices within the same set are adjacent.
Input
The input contains multiple test cases. For each test case, it contains n+1 lines. Line 1: two integers m, n (1<= m <= 10000, 0 <= n <= 100000) indicating that there are m vertices and n edges in the graph. Line 2~n+1: each contains two integers i, j (1 <= i, j <= m), indicating that there is an edge between vertex i and vertex j.
Output
If the graph is a bipartite one, output “Yes”, else output “No”.
Sample
Input
3 3
1 2
2 3
1 3
4 2
1 2
3 4
Output
No
Yes
Source: lily
Comments