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(0, n, left, right);
}
Compilation message (stderr)
popa.cpp: In function 'int rec(int, int, int*, int*)':
popa.cpp:20:32: warning: control reaches end of non-void function [-Wreturn-type]
20 | left[root] = l_c, right[root] = r_c;
| ~~~~~~~~~~~~^~~~~
popa.cpp:20:7: warning: 'root' may be used uninitialized in this function [-Wmaybe-uninitialized]
20 | left[root] = l_c, right[root] = r_c;
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |