시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 512 MB4318828.571%

문제

The town administration has decided to embellish the landscape by building new parks. To make the parks not only look good, but also be useful, they need to carefully choose which neighbourhoods to build the parks in so that the kids from the other neighbourhoods have at least one park near them.

The town consists of $n$ neighbourhoods connected by $n - 1$ roads of a certain length. There is a unique path connecting each neighbourhood to any other neighbourhood. In other words, the neighbourhoods and roads form a tree. Exactly $k$ parks should be built in different neighbourhoods so that the other neighbourhoods have their nearest park as close to them as possible. To be more precise, the administration wants to minimize the maximum distance from a neighbourhood to its closest park.

Help the town administration and determine which neighbourhoods should have a park built in them and determine the maximum distance from a neighbourhood to its closest park.

입력

The first line contains two positive integers $n$ and $k$ ($1 ≤ k ≤ n ≤ 200\,000$), the number of neighbourhoods and the number of parks, respectively.

The $i$-th of the next $n - 1$ lines contains positive integers $a_i$, $b_i$ and $w_i$ ($1 ≤ a_i , b_i ≤ n$, $1 ≤ w_i ≤ 10^9$), which denotes that the neighbourhoods labeled $a_i$ and $b_i$ are connected by a road of length $w_i$.

출력

In the first line print the least possible maximum distance from the problem statement.

In the second line print $k$ positive integers, the labels of the neighbourhoods which will have a park built in them. If there is more than one solution, output any one.

서브태스크

번호배점제한
110

$1 ≤ n ≤ 20$

210

$k = 1$

330

$a_i = i$, $b_i = i + 1$ for all $1 ≤ i ≤ n - 1$

460

No additional constraints.

예제 입력 1

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

예제 출력 1

8
4 5 8

예제 입력 2

5 2
1 2 3
2 3 7
3 4 3
4 5 3

예제 출력 2

3
2 4

예제 입력 3

7 4
1 3 1
1 4 1
2 3 1
5 3 1
4 7 1
4 6 1

예제 출력 3

1
3 4 1 2

힌트

Clarification of the third example: If the parks were built only in neighbourhoods 3 and 4, the maximum distance wouldn’t change, but the city administration wants to build exactly $k$ parks, so two more need to be built somewhere else.

채점 및 기타 정보

  • 예제는 채점하지 않는다.