# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1126429 | TAhmed33 | Building 4 (JOI20_building4) | C++20 | 243 ms | 28844 KiB |
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
typedef long long ll;
typedef long double ld;
const int MAXN = 1e6 + 25;
int a[MAXN][2], n, ans[MAXN];
pair <int, int> f[MAXN][2];
void construct (int pos, int x, int c) {
ans[pos] = c; x -= c == 0;
if (pos == 1) {
return;
}
if (a[pos][c] >= a[pos - 1][0] && f[pos - 1][0].first <= x && x <= f[pos - 1][0].second) {
construct(pos - 1, x, 0);
} else if (a[pos][c] >= a[pos - 1][1] && f[pos - 1][1].first <= x && x <= f[pos - 1][1].second) {
construct(pos - 1, x, 1);
} else {
assert(0);
}
}
void solve () {
cin >> n;
n *= 2;
for (int i = 1; i <= n; i++) {
cin >> a[i][0];
}
for (int i = 1; i <= n; i++) {
cin >> a[i][1];
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |