#P3915. 树的分解
树的分解
Description
Given a tree with vertices and an integer , determine whether it can be partitioned into connected components, each containing exactly vertices.
Input Format
The first line contains an integer , the number of test cases. Then follow test cases:
The first line of each test case contains two integers .
The next lines each contain two integers , denoting the edge . The vertices are labeled .
Output Format
For each test case, output YES or NO.
2
4 2
1 2
2 3
3 4
4 2
1 2
1 3
1 4
YES
NO
Hint
- For of the testdata, .
- For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号