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;
int par[1111];
int solve(int N, int* left, int* right) {
int cur = 0;
int root = 0;
memset(par, -1, sizeof par);
for(int i = 0; i < N; i++) {
right[i] = -1;
left[i] = -1;
}
for(int i = 1; i < N; i++) {
while(cur != -1) {
if(query(cur, i, cur, cur) == true) {
if(right[cur] != -1){
left[i] = right[cur];
par[right[cur]] = i;
}
right[cur] = i;
par[i] = cur;
// cout << "set parent " << i << " " << cur << endl;
break;
}
cur = par[cur];
}
if(cur == -1) {
par[root] = i;
left[i] = root;
root = i;
// cout << "set parent " << i << " " << -1 << endl;
}
cur = 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... |