Submission #62055

#TimeUsernameProblemLanguageResultExecution timeMemory
62055Diuvenpopa (BOI18_popa)C++11
100 / 100
120 ms632 KiB
#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]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...