CF1297E.Modernization of Treeland

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The first line contains an integer tt ( 1t1041 \le t \le 10^4 ) — the number of test cases in the input. This is followed by the test cases themselves.

Each test case begins with a line that contains two integers nn and kk ( 2n31052 \le n \le 3 \cdot 10^5 , 1kn1 \le k \le n ) — the number of cities in Treeland and the number of "dead-end" cities required in the subset SS .

This is followed by n1n-1 lines with road descriptions. Each road is given by two integers xx and yy ( 1x,yn1 \le x, y \le n ; xyx \ne y ) — the numbers of the cities that are connected by this road. It is guaranteed that from every city you can reach any other, moving only by the roads.

The sum of the values of nn for all test cases in the input does not exceed 31053 \cdot 10^5 .

输入格式

For each test case print Yes or No (in any case, upper or lower), depending on whether the answer exists or not. If the answer exists, then print an integer mm ( 1mn1 \le m \le n ) — the number of cities in the found subset. Then print mm different numbers from 11 to nn — the numbers of the cities in the found subset. City numbers can be printed in any order. If there are several answers, print any of them.

输出格式

输入输出样例

  • 输入#1

    4
    10 4
    4 5
    5 2
    2 1
    1 3
    1 9
    9 10
    2 7
    7 8
    5 6
    4 3
    1 2
    2 3
    3 4
    5 3
    1 2
    1 3
    1 4
    1 5
    4 1
    1 2
    2 4
    2 3

    输出#1

    Yes
    9
    1 2 4 5 6 7 8 9 10 
    No
    Yes
    4
    1 3 4 5 
    Yes
    1
    4
首页