Shortest Paths#2968

Shortest Paths

1 sekunt
128 megabaýt
Örän ýeňil

A weighted directed graph and a starting vertex are given.

For each vertex , output the length of the shortest path from to .

Giriş

The first line contains three integers , , (2 \leq n \leq 2000, 1 \leq m \leq 5000): the number of vertices and edges in the graph, and the starting vertex number.

The next lines describe the edges of the graph. Each edge is given by three integers: the starting vertex, the ending vertex, and the weight of the edge. The weight is an integer, and its absolute value does not exceed 10^{15}. The graph may contain multiple edges and loops.

Çykyş

Print lines: for each vertex , print the length of the shortest path from to . If there is no path between and , print "*". If there is no shortest path between and , print "-".

Mysallar

1-nji mysal

Loading
Loading