Submission #419429

#TimeUsernameProblemLanguageResultExecution timeMemory
419429Bill_00Crayfish scrivener (IOI12_scrivener)C++14
100 / 100
615 ms109892 KiB
#include <bits/stdc++.h> using namespace std; char last; int a[1000005][25],cnt,lol[1000005],sz[1000005]; char x[1000005]; void Init() {} int find(int num){ return lol[num]=(lol[num]==num?num:find(lol[num])); } void TypeLetter(char L) { cnt++; x[cnt]=L; sz[cnt]=sz[find(cnt-1)]+1; lol[cnt]=cnt; a[cnt][0]=find(cnt-1); for(int i=1;i<=20;i++){ a[cnt][i]=a[a[cnt][i-1]][i-1]; } } void UndoCommands(int U) { cnt++; lol[cnt]=find(cnt-U-1); sz[cnt]=sz[find(cnt-U-1)]; } char GetLetter(int P) { int siz=sz[find(cnt)]; int k=siz-P-1; int y=find(cnt); for(int i=20;i>=0;i--){ if(k>=(1<<i)){ y=a[y][i]; k-=(1<<i); } } return x[y]; }
#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...