TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

Given some undirected graphs, output their shortest path matrix.

Input Format

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.

Output Format

For each test case, output a matrix A, Aij denoting the shortest path weight from vertex i to vertex j.

Sample Input 1

2
0 1
1 0
3
0 1 -1
1 0 1
-1 1 0

Sample Output 1

0 1
1 0
0 1 2
1 0 1
2 1 0

Hints

Problem Source

Migrated from old NTUJ.

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 2000 65536 4096