Submission #18853

#TimeUsernameProblemLanguageResultExecution timeMemory
18853suhgyuho_williamCrayfish scrivener (IOI12_scrivener)C++98
100 / 100
462 ms95804 KiB
#include <stdio.h> int rear,cnt; int par[1000010][22]; int next[1000010]; int many[1000010]; char a[1000010]; void Init(){ rear = cnt = 0; } void TypeLetter(char L) { int i; rear++; cnt++; next[cnt] = rear; a[rear] = L; par[rear][0] = next[cnt-1]; for(i=1; i<=19; i++){ par[rear][i] = par[par[rear][i-1]][i-1]; } many[cnt] = many[cnt-1]+1; } void UndoCommands(int U) { cnt++; next[cnt] = next[cnt-U-1]; many[cnt] = many[cnt-U-1]; } char GetLetter(int P) { int i,x; int ans; ans = next[cnt]; x = many[cnt]-(P+1); //printf("%d %d\n",ans,x); for(i=19; i>=0; i--){ if(x >= (1 << i)){ ans = par[ans][i]; x -= (1 << i); } } return a[ans]; }
#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...