# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1000603 | biximo | Building 4 (JOI20_building4) | C++17 | 2 ms | 6492 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define N 1000005
using namespace std;
int A[N], B[N], LIS[N], n, minv[N], maxv[N], bt[N];
string ans;
void reconstruct(int st) {
priority_queue<array<int,3>> pq;
for(auto&i: ans) i = 'B';
int c = st, cv = n/2, prev;
while(c) {
ans[c-1] = 'A';
if(c == st || LIS[prev-1] != LIS[c-1]) {
for(int i = c-2; i >= 0 && LIS[i+1] == LIS[c-1]; i --) {
if(A[i] <= B[i+1]) pq.push({maxv[i],minv[i],i});
}
}
if(minv[c-1] <= cv - 1 && cv - 1 <= maxv[c-1]) {
prev = c;
c --;
cv --;
continue;
}
assert(pq.size());
while(pq.top()[2] >= c) pq.pop();
assert(pq.size());
while(pq.top()[1] > cv-1) pq.pop();
assert(pq.size());
cv --;
prev = c;
c = pq.top()[2];
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |