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"
#define maxN 1005
using namespace std;
int solve(int n, int* l, int* d){
for(int i=0;i<n;i++) l[i]=d[i]=-1;
int root,i,j,tmp,pom;
vector <int> v;
root=0;
for(i=1;i<n;i++){
tmp=root;
while(tmp!=-1){
v.push_back(tmp);
tmp=d[tmp];
}
pom=-1;
for(j=v.size()-1;j>=0;j--){
if(!query(v[j],i,i,i)) break;
pom=j;
}
if(pom==-1) {l[i]=-1; d[v.back()]=i;}
if(pom==0) {l[i]=v[0]; root=i;}
if(pom>0) {
l[i]=v[pom];
d[v[pom-1]]=i;
}
v.clear();
}
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... |