제출 #781088

#제출 시각아이디문제언어결과실행 시간메모리
781088Silence크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++17
100 / 100
564 ms85480 KiB
const int mxn = 1e6 + 5; const int k = 20; int cur =0; int par[mxn][k]; int val[mxn],depth[mxn]; void Init() { } void TypeLetter(char L) { ++cur; val[cur] = L - 'a'; depth[cur] = depth[cur - 1] + 1; par[cur][0] = cur - 1; for (int i = 1;i<k;++i){ par[cur][i] = par[par[cur][i - 1]][i - 1]; } } void UndoCommands(int U) { ++cur; depth[cur] = depth[cur - U - 1]; val[cur] = val[cur - U - 1]; par[cur][0] = par[cur - U - 1][0]; for (int i = 1;i<k;++i){ par[cur][i] = par[par[cur][i - 1]][i - 1]; } } char GetLetter(int P) { int v = depth[cur] - P - 1; int pos = cur; for (int i = k - 1;i>=0;--i){ if (v - (1<<i) >= 0){ pos = par[pos][i]; v-=(1<<i); } } return char(val[pos] + '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...