제출 #781075

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