задача 171

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
n = int(input())
graph = []
for i in range(n):
graph.append(list(map(int, input().split())))
for k in range(n):
for i in range(n):
for j in range(n):
graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j])
for i in graph:
print(*i)