RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00613

Parkovi

Unrated 레이팅 미적용
난이도
3s
시간 제한
512MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

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.

제약

Subtask 1 (10 points): \(1 \le n \le 20\)

Subtask 2 (10 points): \(k = 1\)

Subtask 3 (30 points): \(a_{i} = i\), \(b_{i} = i + 1\) for all \(1 \le i \le n - 1\)

Subtask 4 (60 points): No additional constraints.

입력 형식

The first line contains two positive integers \(n\) and \(k\) (\(1 \le k \le n \le 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@@RISE_MATH_BLOCK_0@@i\) and \(w@@RISE_MATH_BLOCK_1@@i\), b\(i \le n\), \(1 \le w\)\(i \le 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.

서브태스크
서브태스크점수설명

1

10점

\(1 \le n \le 20\)

2

10점

\(k = 1\)

3

30점

\(a_{i} = i\), \(b_{i} = i + 1\) for all \(1 \le i \le n - 1\)

4

60점

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
출력
8
4 5 8
예제 2
입력
5 2
1 2 3
2 3 7
3 4 3
4 5 3
출력
3
2 4
예제 3
입력
7 4
1 3 1
1 4 1
2 3 1
5 3 1
4 7 1
4 6 1
출력
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.

문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2021/2022 Contest 4

평가 및 의견

Parkovi

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Parkovi

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8