Given some undirected graphs, output their shortest path matrix.
Each test case starts by a number n (1<=n<=500), followed by an n x n matrix. Let the matrix be D, Dij denoting the edge weight from vertex i to vertex j. If there is no path from i to j, then Dij=-1.
For each test case, output a matrix A, Aij denoting the shortest path weight from vertex i to vertex j.
2 0 1 1 0 3 0 1 -1 1 0 1 -1 1 0
0 1 1 0 0 1 2 1 0 1 2 1 0
Migrated from old NTUJ.
No. | Testdata Range | Score |
---|