#include "popa.h"
#include <iostream>
#include <vector>
using namespace std;
int solve(int n, int Lson[], int Rson[]){
for(int i=0; i<n; i++) Lson[i]=Rson[i]=-1;
vector<int> S; S.push_back(0);
for(int i=1; i<n; i++){
// for(int x:S) cout<<x<<' ';
// cout<<'\n';
if(query(i,i,S.back(),i)){
vector<int> V;
V.push_back(S.back()); S.pop_back();
while(!S.empty()){
int j=S.back();
if(!query(i,i,j,i)) break;
V.push_back(j); S.pop_back();
}
for(int i=0; i<(int)V.size()-1; i++){
Rson[V[i+1]]=V[i];
}
Lson[i]=V.back();
S.push_back(i);
}
else S.push_back(i);
}
for(int sz=S.size(), i=sz-1; i>0; i--){
Rson[S[i-1]]=S[i];
S.pop_back();
}
// for(int i=0; i<n; i++) cout<<Lson[i]<<' ';
// cout<<'\n';
// for(int i=0; i<n; i++) cout<<Rson[i]<<' ';
// cout<<'\n';
return S[0];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
376 KB |
Output is correct |
2 |
Correct |
15 ms |
440 KB |
Output is correct |
3 |
Correct |
12 ms |
496 KB |
Output is correct |
4 |
Correct |
11 ms |
496 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
100 ms |
596 KB |
Output is correct |
2 |
Correct |
112 ms |
596 KB |
Output is correct |
3 |
Correct |
57 ms |
596 KB |
Output is correct |
4 |
Correct |
108 ms |
632 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
120 ms |
632 KB |
Output is correct |
2 |
Correct |
107 ms |
632 KB |
Output is correct |
3 |
Correct |
113 ms |
632 KB |
Output is correct |
4 |
Correct |
108 ms |
632 KB |
Output is correct |