forked from ngthanhtrung23/CompetitiveProgramming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathE.cpp
More file actions
42 lines (31 loc) · 898 Bytes
/
E.cpp
File metadata and controls
42 lines (31 loc) · 898 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
#include <bits/stdc++.h>
using namespace std;
int n, c[11][11];
int readCol(int i, int j, int n) {
j <= n ? (cin >> c[i][j], readCol(i, j+1, n)) : 1;
}
int readRow(int i, int n) {
i <= n ? (readCol(i, 1, n), readRow(i+1, n)) : 1;
}
int floydJ(int k, int i, int j, int n) {
j <= n ? (c[i][j] = min(c[i][j], c[i][k] + c[k][j]), floydJ(k, i, j+1, n)) : 1;
}
int floydI(int k, int i, int n) {
i <= n ? (floydJ(k, i, 1, n), floydI(k, i+1, n)) : 1;
}
int floydK(int k, int n) {
k <= n ? (floydI(k, 1, n), floydK(k+1, n)) : 1;
}
int getCol(int i, int j, int n) {
return j <= n ? max(c[i][j], getCol(i, j+1, n)) : 0;
}
int getRow(int i, int n) {
return i <= n ? max(getCol(i, 1, n), getRow(i+1, n)) : 0;
}
int main() {
cin >> n;
readRow(1, n);
floydK(1, n);
int res = getRow(1, n);
cout << res << endl;
}