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

PROGRAMMING:WLS robot

Luz5年前 (2021-05-10)题库483
All the robots in WLS need to go back to WLS.
There are robots at each point, and WLS has a map with n points and M one-way paths.
Now I give you this map. There are k robots that need to be recalled, so he will ask you k times. Each time, please answer what is the shortest distance for the robot to return to the base( Base is point n)
###Input format:
The first line has three numbers: 1 < = n < = 500, 1 < = m < = 200000, 1 < = k < = 100.
The following M lines, each line gives three numbers, 1 < = t$$_ 1$$,t$$_ 2$$<=n,1<=w<=1e9.
Denotes t$$_ 1 $$to t$$_ There is a path of length w (note that the path is unidirectional, which means that the path can only start from t$$_ 1 $$to t$$_ 2 $$, unable to start from t$$_ 2 $$arrival t$$_ 1$$)
Finally, K lines, each line is an integer in the range of 1 ~ n, which indicates the shortest distance for the robot at this point to return to the base.
###Output format:
Each query outputs an integer to represent the distance. If not, output - 1
###Input example:
Here is a set of inputs. For example:
```in
5 5 3
2 3 1
3 4 1
4 5 1
2 5 1
3 5 1
one
two
four
```
###Output example:
The corresponding output is given here. For example:
```out
-1
one
one
```







answer:If there is no answer, please comment