#P5295. [北京省选集训2019] 图的难题
[北京省选集训2019] 图的难题
Background
The title is fake.
Problem Description
Xiao D encountered a problem in a graph theory exercise book:
The book shows an undirected graph and asks you to color each edge either black or white, such that the subgraph formed by all white edges has no cycles, and the subgraph formed by all black edges also has no cycles.
No matter how she tries, Xiao D feels that the problem in the book has no solution. She wants you to help confirm this.
Since this problem has many subtasks, each time Xiao D will give you the number of vertices , the number of edges , and the full edge set. You only need to tell Xiao D whether a solution exists.
Input Format
The first line contains a positive integer , denoting the number of test cases.
For each test case, the first line contains two positive integers , with the meaning as described in the statement.
Then follow lines. Each line contains two positive integers , denoting an undirected edge from to .
Output Format
Output lines. For each test case, output Yes if a solution exists, otherwise output No.
3
3 3
1 2
1 3
2 3
2 3
1 2
1 2
1 2
4 6
1 2
1 3
2 4
1 3
2 3
3 4
Yes
No
Yes
Hint
Constraints
For of the testdata: .
For of the testdata: .
For of the testdata: .
For of the testdata: , , .
Translated by ChatGPT 5