| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 128 MB | 13 | 0 | 0 | 0.000% |
In Athens 2004 Olympic Games there were many Olympic sites (Stadiums, Olympic Village, Press Center, Offices, etc.). For the athletes, officials and press people to move fast between Olympic sites, Athens created what were called "Olympic Avenues" where only Olympic buses could move. Each Olympic avenue connects two Olympic sites. Not all Olympic sites are connected directly by an Olympic avenue. Each Olympic avenue connects exactly two Olympic sites. A bus driver is traveling from one Olympic site to another and she wants to travel only on the Olympic Avenues. Given the information about the Olympic sites and avenues, you are to help her to find a shortest route between two Olympic sites using only Olympic avenues.
The first line contains one integer: the number of Olympic sites, N, 5 ≤ N ≤ 50. Line 2 contains two integers S and F: the numbers of the starting and the ending sites of the route. The next line contains one integer L: the number of Olympic avenues. The following L lines describe these Olympic avenues. Each of these lines contain three integers I, J, and D: the first two are the Olympic sites I and J that are connected by the avenue and the third integer D is the distance between I and J. This way, the input is organized in the following form:
N S F L I1 J1 D1 I2 J2 D2 . . . IL JL DL
The first line is to contain one integer: the length of the shortest route from S to F. The second line is to contain a sequence of integers: the numbers of the Olympic sites visited on the shortest route, where S is the first integer in the sequence and F is the last integer in the sequence.
6 1 4 8 1 2 12 1 6 8 1 3 20 6 5 10 5 4 7 5 3 2 3 4 6 2 3 5
23 1 2 3 4