EIBIPARTITE - Bipartite graph

Xem dạng PDF

Gửi bài giải

Điểm: 1,00 (OI)
Giới hạn thời gian: 1.0s
Giới hạn bộ nhớ: 256M
Input: stdin
Output: stdout

Nguồn bài:
Hà Minh Ngọc
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch

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 ≤ 10^5)~. 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

Example Output

Yes
No

Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.