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>
#include "popa.h"
using namespace std;
const int MaxN = 10010;
int lf[MaxN], rg[MaxN];
int dfs(int l, int r) {
if (l > r) return -1;
int a = l, b = r;
while (1) {
if (query(l, r, a, a)) {
lf[a] = dfs(l, a - 1);
rg[a] = dfs(a + 1, r);
return a;
}
if (query(l, r, b, b)) {
lf[b] = dfs(l, b - 1);
rg[b] = dfs(b + 1, r);
return b;
}
a++;
b--;
}
}
int solve(int n, int* left, int* right) {
int root = dfs(0, n - 1);
for (int i = 0; i < n; i++) {
left[i] = lf[i];
right[i] = rg[i];
}
return root;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |