-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathback_11403.cpp
More file actions
44 lines (39 loc) · 803 Bytes
/
back_11403.cpp
File metadata and controls
44 lines (39 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <iostream>
using namespace std;
int map[101][101];
int main()
{
int a;
cin >> a;
for (int i = 1; i <= a; i++)
{
for (int j = 1; j <= a; j++)
{
cin >> map[i][j];
if (map[i][j] == 0)
map[i][j] = 99999;
}
}
for (int k = 1; k <= a; k++)
{
for (int i = 1; i <= a; i++)
{
for (int j = 1; j <= a ;j++)
{
map[i][j] = min(map[i][j],map[i][k] + map[k][j]);
}
}
}
for (int i = 1; i <= a; i++)
{
for (int j =1; j <= a; j++)
{
if (map[i][j] == 99999)
cout << "0 ";
else
cout << map[i][j] << " ";
}
cout << "\n";
}
return 0;
}