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

18393번 - TRIP 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB852100.000%

문제

Wajed works as a driver in a software company. He is responsible for driving employees from/to their home to the company's main office. Every day he drives from the main office to the home of all employees to pick them up, then he takes them to the office. He should save time, and fuel, so he wants to find the best route to do this with the least cost. Your task is to find the shortest route that begins at the company, picks all the employees and returns back to the company's office.

입력

The first line contains the number of test cases: 0 < T < 100. Each next T test cases begins with a line containing two integers: N, M, the number of intersections N (all numbered from 0 to N-1) and roads M in the city. The company is at the intersection numbered 0. M next lines each contains three integers X, Y, andِ D (0 <= X, Y, D <= 1000): the intersections X and Y are connected by a bidirectional road of length D. The following line contains a single integer S (1 <= S <= 10), the number of employees that should be gathered. The subsequent S lines each contain one integer indicating the intersection at which each engineer’s home is located. It is possible to gather all the employees from the company.

출력

For each test case, output a line containing a single integer, the length of the shortest possible trip from the company, gathering all the employees, and returning to the company.

제한

예제 입력 1

1
4 6
0 1 1
1 2 1
2 3 1
3 0 1
0 2 5
1 3 5
3
1
2
3

예제 출력 1

4

힌트

출처

ICPC > Regionals > Asia West Continent > Afghanistan > ICPC Asia Kabul Regional Contest 2019 2번

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

출처

대학교 대회

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

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