-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbj_11403.cpp
More file actions
61 lines (52 loc) · 1.2 KB
/
bj_11403.cpp
File metadata and controls
61 lines (52 loc) · 1.2 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <iostream>
#include <algorithm>
#include <utility>
#include <map>
#include <stack>
#include <queue>
#include <string>
using namespace std;
int Map[101][101] = {};
int N;
int main() {
cin.tie(NULL);
cout.tie(NULL);
ios_base::sync_with_stdio(false);
cin >> N;
for(int i = 0; i<N; i++) {
for(int j = 0; j<N; j++) {
cin >> Map[i][j];
}
}
for(int i = 0; i<N; i++) {
for(int j = 0; j<N; j++) {
if(Map[i][j] == 1) {
for(int k = 0; k<N; k++) {
if(Map[j][k] == 1) {
Map[i][k] = 1;
}
}
}
}
}
for(int i = 0; i<N; i++) {
for(int j = 0; j<N; j++) {
if(Map[i][j] == 1) {
for(int k = 0; k<N; k++) {
if(Map[j][k] == 1) {
Map[i][k] = 1;
}
}
}
}
}
for(int i = 0; i<N; i++) {
for(int j = 0; j<N; j++) {
if(Map[i][j] == 2)
cout << 1 << " ";
else
cout << Map[i][j] << " ";
}
cout << "\n";
}
}