-->
当前位置:首页 > 题库

PROGRAMMING:Super Marie

Luz5年前 (2021-05-10)题库572
Suppose there are n castles, numbered 1 to N. some castles are directly connected by roads, and some castles are not directly connected by roads. Mario is now ready to go from one castle to another. It has a magic wand, which can instantly pass a road, that is, it can pass this road in 0 time, but the magic wand can only be used once at most. Mario wants to get to his destination in the shortest time. Please write a program to choose a route for Mario and where to use the magic wand. Assume that all roads are two-way, ensure that you can reach the destination from the starting point.
![ mario.jpg](~/99398b94-6a5d-49ce-88ab-c122139f213a.jpg)
###Input format:
Enter four integers n, s, t, m in the first line, which respectively represent the number of Castles (numbered from 1 to N, n does not exceed 10000), the starting point s where Mario is, the end point t where he wants to go, and the number of roads between castles. Next, m lines, each line contains three positive integers a, B and C, which means that there is a road directly connected between castle a and Castle B, and it takes C minutes to pass through the road.
###Output format:
The output is two integers with space interval. The first integer is the shortest time required for Mario from the starting point to the destination; The second integer indicates the place where the magic wand is used, that is, the castle number. If there are multiple possible places, the lowest number will be output.
###Input example:
```in
4 1 4 4
1 2 9
2 4 1
1 3 3
3 4 5
```
###Output example:
```out
1 1
```







answer:If there is no answer, please comment