#include <bits/stdc++.h>
#include "popa.h"
using namespace std;
int solve(int N, int *L, int *R) {
for (int i = 0; i < N; i++) {
L[i] = R[i] = -1;
}
int root = -1;
for (int i = 0; i < N; i++) {
if (root == -1) {
root = i;
continue;
}
vector<int> nodes;
int cur = root;
while (cur != -1) {
nodes.push_back(cur);
cur = R[cur];
}
for (int idx = nodes.size()-1; idx >= 0; idx--) {
cur = nodes[idx];
if (query(cur, cur, cur, i)) {
R[cur] = i;
break;
}
if (idx > 0) {
int par = nodes[idx-1];
R[par] = i;
}
R[cur] = L[i];
L[i] = cur;
}
}
return root;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
not a valid binary tree |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
376 KB |
not a valid binary tree |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
372 KB |
not a valid binary tree |
2 |
Halted |
0 ms |
0 KB |
- |