영어 원문입니다. 원문의 수식·표를 글자로 옮겨 모양이 다를 수 있습니다. 정확한 내용은 원문 페이지에서 확인하세요. 원문 페이지 열기 (새 창)
Problem
This is how a poem by Gustaf Fröding begins: Jan Ersa ägde Nackabyn, Per Persa ägde Backabyn i By i Västra Ed. Jan Ersa, Per Persa, de höllo aldrig fred.
When Jan Ersa and Per Persa, in their old age, moved into the city, they made sure to end up as far away from each other as possible. Write a program that reads information about the streets in the city and then determines between which two houses the shortest path is the longest, and then outputs the houses and the length of this path. All streets are bidirectional.
(그림은 원문 저장소에서 볼 수 있습니다)
Figure 1: The map shows all houses and streets of the city in the example. We also see the red houses where Jan Ersa and Per Persa now live. These two houses (numbers 1 and 9) are the houses in the city that are farthest away from each other (4900 meters).
Input
The first line contains the integer N (2 ≤ N ≤ 700), the number of houses in the city. The houses are numbered from 1 to N.
The second line contains the integer V (1 ≤ V ≤ 2000), the number of streets.
The following V lines each contain the integers a, b, l (1 ≤ a,b ≤ N, a ≠ b, 1 ≤ l ≤ 100), describing that there is a street between houses a and b with length l (given in hundreds of meters). There is at most one street between each pair of houses. It is guaranteed that it is possible to get from any house to any other house.
Output
Print three integers on one line: the numbers of the two houses farthest away from each other, and the distance between them in meters. If there are several pairs of houses at this distance, you may output any of them.
Scoring
Your solution will be tested on a set of test groups. To earn points for a group, you must pass all test cases in that group.
| Group | Points | Constraints |
|---|---|---|
| 1 | 30 | N ≤ 25, V ≤ 75 |
| 2 | 70 | No additional constraints. |
예제
예제 1
15 27 1 12 10 1 2 9 2 12 9 6 12 9 3 6 9 2 3 8 3 12 10 3 4 8 4 13 6 5 13 11 5 6 8 4 6 11 4 5 15 6 7 12 7 8 8 8 11 6 9 11 11 9 10 8 7 10 10 10 11 14 8 15 11 5 15 9 5 7 13 5 8 12 5 14 12 13 14 16 14 15 8
1 9 4900