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

33531번 - Doner Time! 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 (추가 시간 없음) 2048 MB28241982.609%

문제

Every student knows the practice: after having had one too many drinks in the \PUB, you will go to the Doner Shop to treat yourself with some comfort food.

But experience tells you that you and your friends will not recall the way to the Doner Shop when you are drunk. Besides there are a lot of Doner Shops in the city. Therefore you decide to write a program that will tell you how far away the nearest Doner store is from your current location. And tells you with Doner store is closest.

You may assume you can reach at least one Doner Shop from your current location. You always start at the crossing numbered 1.

입력

A line with two integers: $N, 1 < N \le 10000,ドル the number of crossings in the city, and $S, 1 < S \le 100000,ドル the number of streets in the city.

$S$ lines with three space seperated integers, $a, b, l, 1 \le a, b \le N , 1 \le l \le 1000$. Which indicate that a street with length $l$ connects crossing a with crossing b. All streets are bi-directional.

An integer $m, 1 \le m \le 1000,ドル the number of Doner Shops in the city.

$M$ lines with one integer $c, 1 \le c \le N$ which indicates that on crossing $c$ you can find a Doner shop.

출력

One line with two space separated integers:

$C$ The number of the crossing at which you can find the closest Doner Shop. If multiple doner stores are equally far away from you, give the one that has the lowest number.

$L$ The length of the shortest route to the closest Doner Shop.

제한

예제 입력 1

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

예제 출력 1

4 5

예제 입력 2

11 13
1 2 5
2 3 30
2 4 16
4 3 17
2 5 6
5 6 7
6 10 8
10 9 12
8 9 11
8 11 14
7 8 10
1 7 9
5 8 13
3
11
10
3

예제 출력 2

10 26

힌트

출처

University > Delft University of Technology > Freshmen Programming Contest 2018 D번

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

출처

대학교 대회

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

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