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

PROGRAMMING:Single source shortest path

Luz5年前 (2021-05-10)题库452
Please write a program to find the shortest path length of a given positive weight digraph. The graph contains n vertices, numbered from 0 to n-1, with vertex 0 as the source point.
###Input format:
Enter two positive integers n and E in the first line to represent the number of vertices and edges of the graph, where n does not exceed 20000 and E does not exceed 1000. Next, line e represents the information of each edge, and each line contains three non negative integers a, B, and C, where a and B represent the endpoint number of the edge, and C represents the weight. The sides are not arranged in end numbered order.
###Output format:
The output is a line of integers, which is the shortest path length from the source point 0 to each vertex (excluding the source point to the source point) arranged in the order of vertex number, and each integer is followed by a space. If there is no shortest path from the source point to a vertex, the length of the path is not output.
###Input example:
```in
4 4
0 1 1
0 3 1
1 3 1
2 0 1
```
###Output example:
```out
1 1
```







answer:If there is no answer, please comment