Submit | All submissions | Best solutions | Back to list |
EIBIPARTITE - Bipartite graph |
Given graph G containing n vertices, m edges, and a simple graph, write a program to check whether the graph is Bipartite or not.
Input
The first line contains an integer T, the number of test cases. Next is T test cases, each test case includes:
The first line contains 2 numbers n, m (n, m ≤ 105). Where n is the number of vertices, m is the number of edges. The vertices are numbered from 0 to n-1.
In the next m lines, each line contains two integers u, v (0 ≤ u, v <n) that are the edges of the graph.
The first line contains an integer T, the number of test cases. Next is T test cases, each test case includes:
The first line contains 2 numbers n, m (n, m ≤ 105). Where n is the number of vertices, m is the number of edges. The vertices are numbered from 0 to n-1.
In the next m lines, each line contains two integers u, v (0 ≤ u, v <n) that are the edges of the graph.
Output
Include T lines, output "Yes" if the graph is Bipartite, otherwise output "No".
Example
Input:
2
3 2
0 2
1 2
3 3
0 2
1 2
0 1
Output:
Yes
No
Added by: | Ha Minh Ngoc |
Date: | 2017-10-24 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | CSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG FSHARP GO JAVA JS-MONKEY NODEJS PHP PYTHON PYPY PYPY3 PYTHON3 RUBY SQLITE SWIFT VB.NET |