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

14548번 - The fastest road to banikoara 다국어

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

문제

Codjo: I am ready for the trip to Banikoara

Bossi: Let us go through Parakou

Assiba: No, the fastest road to go to Banikoara is through Djougou

You are responsible to write a program which, given a list of towns and distances separating these towns, gives the shortest distance to travel from a town A to a town B

입력

The first line of input contains a single integer P, (1 ≤ P ≤ 1000), which is the number of data sets that follow. Each data set begins with a line containing the number N of the remaining lines in the dataset (1 ≤ N ≤ 500), followed by a space, followed by the name of a departure town, followed by a space, followed by the name of a destination town. Each of these N lines contains a name of a departure town, followed by a space, followed by a name of a destination town, followed by the distance (in kilometers) between the two towns. The distance will be an integer and the name of town will be a string formed with characters [a-z] [A-Z] and with the sign “-”.

출력

For each data set, you must generate a single output line containing the name of a town A and a space, followed by the name of town B, followed by a space, followed by the shortest distance to travel between towns A and B.

제한

예제 입력 1

1
4 Dassa-Zoume Banikoara
Dassa-Zoume Djougou 270
Banikoara Djougou 211
Parakou Banikoara 284
Parakou Dassa-Zoume 225

예제 출력 1

Dassa-Zoume Banikoara 481

힌트

출처

ICPC > Regionals > Africa and Arab > South Africa Regional Contest > Beninese Collegiate Programming Contest > The 2016 Beninese Collegiate Programming Contest F번

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

출처

대학교 대회

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

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