Submission #286569

#TimeUsernameProblemLanguageResultExecution timeMemory
286569amiratouCrayfish scrivener (IOI12_scrivener)C++14
12 / 100
1080 ms120824 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back const int L=21,MX=(int)(1e6+7); int up[MX][L],d[L],idx; char car[MX]; vector<int> vec[MX]; void Init() { } void TypeLetter(char L) { vec[idx].pb(idx+1); d[idx+1]=d[idx]+1; up[idx+1][0]=idx; for (int i = 1; i < L; ++i) up[idx+1][i]=up[up[idx+1][i-1]][i-1]; car[idx+1]=L; idx++; } void UndoCommands(int U) { vec[up[idx-U][0]].pb(idx+1); d[idx+1]=d[up[idx-U][0]]+1; up[idx+1][0]=up[idx-U][0]; for (int i = 1; i < L; ++i) up[idx+1][i]=up[up[idx+1][i-1]][i-1]; car[idx+1]=car[idx-U]; idx++; } char GetLetter(int P) { assert((d[idx]-1)>=P); //cerr<<P<<","<<d[idx]<<"\n"; int k=d[idx]-1-P,a=idx; for (int i = 0; i < L; ++i) if((k>>i)&1)a=up[a][i]; return car[a]; }
#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...