-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
35 lines (33 loc) · 743 Bytes
/
Copy pathmain.cpp
File metadata and controls
35 lines (33 loc) · 743 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
#include <bits/stdc++.h>
using namespace std;
auto sol = [](int n) {
vector ret(n, vector(n, 0));
int val = 0;
for (int j = n - 2; j >= 0; j--) {
int acc = 0;
for (int i = 1; i <= n - 1; i++) {
int mn = 0, mx = 0;
for (int k = i; k <= n - 1; k++) {
mn += ret[k][n - 1];
mx += ret[k][j + 1];
}
for (int k = j + 2; k <= n - 1; k++) {
mn += ret[i][k - 1];
mx += ret[n - 1][k];
}
ret[i][j] = (val + 1) - (acc + mn);
acc += ret[i][j];
val = acc + mx;
}
}
return ret;
};
int main() {
cin.tie(0)->sync_with_stdio(0);
int n; cin >> n;
auto res = sol(n);
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) cout << res[i][j] << ' ';
cout << '\n';
}
}