Submission #62514

#TimeUsernameProblemLanguageResultExecution timeMemory
62514zetapiCrayfish scrivener (IOI12_scrivener)C++14
34 / 100
1075 ms66412 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define ll long long #define itr ::iterator typedef pair<int,int> pii; const int MAX=1e6; char last; char X[MAX]; int ind,size[MAX],par[MAX],Parent[MAX][21]; void Init() { } int get(int u) { if(par[u]==u or (X[u]>='a' and X[u]<='z')) return u; return par[u]=get(par[u]); } void TypeLetter(char L) { ++ind; X[ind]=L; par[ind]=get(ind-1); size[ind]=size[par[ind]]+1; Parent[ind][0]=par[ind]; for(int A=1;A<21;A++) Parent[ind][A]=Parent[Parent[ind][A-1]][A-1]; return ; } void UndoCommands(int U) { ++ind; par[ind]=get(ind-U-1); size[ind]=size[par[ind]]; Parent[ind][0]=par[ind]; for(int A=1;A<21;A++) Parent[ind][A]=Parent[Parent[ind][A-1]][A-1]; return ; } char GetLetter(int P) { P++; int cur=ind; for(int A=20;A>=0;A--) { if(size[Parent[cur][A]]>=P) cur=Parent[cur][A]; } return X[cur]; } /*signed main() { ios_base::sync_with_stdio(false); TypeLetter('a'); TypeLetter('b'); TypeLetter('d'); UndoCommands(2); UndoCommands(1); cout<<GetLetter(2); //cout<<ind<<" "<<par[ind]<<"\n"; return 0; }*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...