#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
ll ans[1009][1009];
ll a[1009];
ll n;
ll depth[1009][3];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
cin >> n;
for(ll i = 0; i < n; ++i)
cin >> a[i];
for(ll i = n-1; i >= 0; --i){
for(ll j = i+1; j < n; ++j){
pll mini = {1e9, 1e9};
for(ll k = 0; k < 3; ++k)
mini = min(mini, {depth[j][k], k});
ans[i][j] = mini.ss;
depth[i][mini.ss] = max(mini.ff+1, depth[i][mini.ss]);
}
}
for(ll i = 1; i < n; ++i){
for(ll j = 0; j < i; ++j){
//cout << j << ' ' << i << ' ';
cout << ans[j][i]+1 << ' ';
}
cout << '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Correct |
1 ms |
504 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
6 |
Correct |
1 ms |
492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Correct |
1 ms |
504 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
6 |
Correct |
1 ms |
492 KB |
Output is correct |
7 |
Correct |
1 ms |
620 KB |
Output is correct |
8 |
Correct |
49 ms |
8428 KB |
Output is correct |
9 |
Correct |
1 ms |
748 KB |
Output is correct |
10 |
Correct |
1 ms |
748 KB |
Output is correct |
11 |
Correct |
42 ms |
7532 KB |
Output is correct |
12 |
Correct |
48 ms |
8320 KB |
Output is correct |
13 |
Correct |
42 ms |
7660 KB |
Output is correct |
14 |
Correct |
3 ms |
1260 KB |
Output is correct |
15 |
Correct |
40 ms |
7660 KB |
Output is correct |
16 |
Correct |
40 ms |
7660 KB |
Output is correct |
17 |
Correct |
41 ms |
7808 KB |
Output is correct |
18 |
Correct |
40 ms |
7660 KB |
Output is correct |
19 |
Correct |
41 ms |
7788 KB |
Output is correct |
20 |
Correct |
41 ms |
7788 KB |
Output is correct |
21 |
Correct |
42 ms |
7660 KB |
Output is correct |
22 |
Correct |
45 ms |
7680 KB |
Output is correct |
23 |
Correct |
51 ms |
8300 KB |
Output is correct |