-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11403.cpp
More file actions
37 lines (33 loc) · 760 Bytes
/
11403.cpp
File metadata and controls
37 lines (33 loc) · 760 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
#include <iostream>
#include <vector>
#include <algorithm>
#define io ios::sync_with_stdio(false); cin.tie(0);
using namespace std;
int main()
{
io;
int N;
cin>>N;
vector<vector<int>> graph(N+1,vector<int>(N+1));
for(int i=1;i<=N;i++){
for(int j=1;j<=N;j++){
cin>>graph[i][j];
if(graph[i][j]==0) graph[i][j]=101;
}
}
for(int k=1;k<=N;k++){
for(int i=1;i<=N;i++){
for(int j=1;j<=N;j++){
graph[i][j]=min(graph[i][j],graph[i][k]+graph[k][j]);
}
}
}
for(int i=1;i<=N;i++){
for(int j=1;j<=N;j++){
if(graph[i][j]!=101)cout<<"1 ";
else cout<<"0 ";
}
cout<<'\n';
}
return 0;
}