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

PROGRAMMING:The shortest way back to the court

Luz5年前 (2021-05-10)题库362
In the school competition every year, all the students who enter the final will get a beautiful T-shirt. But every time our staff transport hundreds of clothes back from the store, they are very tired! So now they want to find the shortest route from the store to the stadium. Can you help them?
[test case: Hao Zongyin, IOT engineering level 16]
###Input format:
The input includes multiple sets of data. The first line of each group of data is two integers n and m (n < = 100, m < = 10000). N means that there are several intersections on the street, the intersection marked with 1 is the location of the store, the intersection marked with n is the location of the stadium, and M means that there are several roads. N = M = 0 indicates the end of input. Next, line m, each line contains three integers a, B, C (1 < = a, B < = n, 1 < = C < = 1000), indicating that there is a road between intersection a and B, and our staff need C minutes to walk this road.
Input to ensure that there is at least one route from the store to the stadium.
###Output format:
For each group of input, the output line indicates the shortest time for the staff to walk from the store to the stadium
###Input example:
Here is a set of inputs. For example:
```in
4 6
1 2 1
1 3 3
2 3 1
2 4 1
3 4 1
1 4 2
```
###Output example:
The corresponding output is given here. For example:
```out
two
```







answer:If there is no answer, please comment