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"
int dfs(int l,int r,int *Left,int *Right) {
//degenerate case
if (l > r) return -1;
else if (l == r) {
Left[l] = Right[l] = -1;
return l;
}
int s = l, e = r;
int root = -1;
while (l <= r) {
int m = (l + r) >> 1;
if (query(s, e, l, m)) root=m,r = m - 1;
else l = m + 1;
}
//root chk
Left[root] = dfs(s, root - 1, Left, Right);
Right[root] = dfs(root+1,e, Left, Right);
return root;
}
int solve(int N, int *Left, int *Right) {
return dfs(0, N-1, Left, Right);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |