Submission #1113129

#TimeUsernameProblemLanguageResultExecution timeMemory
1113129vjudge1Editor (BOI15_edi)C++17
100 / 100
118 ms28260 KiB
#include<bits/stdc++.h> using namespace std; int vl[300100],bj[300100][20],lev[300100]; int go(int x,int t){ if(lev[x]<t)return x; for(int i=20;i--;) if(lev[bj[x][i]]>=t) x=bj[x][i]; return bj[x][0]; } int main(){ cin.tie(0)->sync_with_stdio(0); int n; cin>>n; for(int i=1;i<=n;i++){ int x; cin>>x; if(x<0){ lev[i]=-x; bj[i][0]=go(go(i-1,lev[i])-1,lev[i]); for(int j=1;j<20;j++) bj[i][j]=bj[bj[i][j-1]][j-1]; }else vl[i]=x; cout<<vl[go(i,1)]<<'\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...