|
Лимит времени 1000/1000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Problem description
Find the shortest path from vertex S to all others in directed graph.
Input
Line 1: Two integers: N - number of vertices, S - starting vertex (1 ≤ S ≤ N ≤ 100).
Line 2..N+1: Adjacency matrix.
Output
Write N integers - distances to all vertices, if there isn't any path write -1.
Example
| stdin |
stdout |
4 4
0 1 1 1
0 0 1 0
0 0 0 0
1 1 0 0 |
1 1 2 0 |
Для отправки решений необходимо выполнить вход.
|