# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
647079 | georgievskiy | popa (BOI18_popa) | C++14 | 0 ms | 0 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 "popa.h";
#include <bits/stdc++.h>
using namespace std;
int rec(int l, int r, int* left, int* right) {
if (l >= r)
return -1;
if (l + 1 == r)
return l;
int root;
for (int i = l; i < r; i++) {
if (query(l, r + 1, i, i)) {
root = i;
break;
}
}
int l_c = rec(l, root, left, right);
int r_c = rec(root + 1, r, left, right);
left[root] = l_c, right[root] = r_c;
}
int solve(int n, int* left, int* right) {
fill(left, left + n, -1), fill(right, right + n, -1);
return rec(l, r, left, right);
}