Logo
(追記) (追記ここまで)

9504번 - Delta Quadrant 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 128 MB148861.538%

문제

Much of the Delta Quadrant remains unexplored, but it is known that there are many dangerous regions inhabited by warring races. Yet, there is a small number of declared neutral zones that reach from planet to planet in which it is safe to travel.

A critical summit is planned, but it is on hold until a quorum of its members is attained. To reach this quorum, almost all of the delegates from the Delta Quadrant must be fetched and brought to the same location, where the Enterprise can pick them up for the summit.

The Enterprise is on its way to the Delta Quadrant. You must find the fastest way, using a single ship leaving from any one of the planets in the Delta Quadrant and returning to that same planet, to visit all but a given number of planets.

There are N planets and N − 1 safe paths through neutral zones connecting the planets. Each path has a known time duration required for traversal. Find the shortest time required, starting from an arbitrary planet, to visit N − k planets, and return.

입력

The first line contains T, the number of problems; 1 ≤ T ≤ 50. Each problem instance starts with a line with two integers, N, the number of planets, and k, the count of planets that need not be visited; 2 ≤ N ≤ 10, 000 and 0 ≤ k ≤ min(N − 1, 20). Following that are N − 1 lines, each containing three integers, which are, in order, the source and destination planet numbers (from 0 to N − 1) and then the time required to traverse that path. The time is between 0 and 1, 000, 000, inclusive. The input graph will be connected.

출력

For each problem instance, print a single integer representing the final distance of travel required.

제한

예제 입력 1

3
2 0
0 1 3000
4 1
0 1 81
1 2 41
2 3 59
9 2
0 1 1000
1 2 1200
0 3 1000
3 4 1200
0 5 1000
5 6 1200
0 7 1800
7 8 600

예제 출력 1

6000
200
13200

힌트

출처

ICPC > Regionals > North America > Pacific Northwest Regional > 2013 Pacific Northwest Region Programming Contest D번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /