Submission #31142

#TimeUsernameProblemLanguageResultExecution timeMemory
31142cscandkswonCrayfish scrivener (IOI12_scrivener)C++14
100 / 100
703 ms92976 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN=1000005; int N, nod, now, cmd; int spt[MAXN][21], A[MAXN], L[MAXN]; char let[MAXN]; void Init() {} void TypeLetter(char c) { int i, p; A[++cmd]=now; let[++nod]=c; L[nod]=L[now]+1; spt[nod][0]=now; now=nod; for(i=1, p=now; ; i++){ if(spt[spt[p][i-1]][i-1]==0) break; spt[p][i]=spt[spt[p][i-1]][i-1]; } } void UndoCommands(int U) { A[++cmd]=now; now=A[cmd-U]; } char GetLetter(int P) { int i, p=now, q=L[now]-P-1; for(i=20; i>=0; i--)if((1<<i)&q){ p=spt[p][i]; } return let[p]; }
#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...