제출 #225710

#제출 시각아이디문제언어결과실행 시간메모리
225710spdskatr크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++14
100 / 100
535 ms74976 KiB
#include <cstdio> #include <cstdlib> #include <algorithm> #include <vector> using namespace std; int cnt = 1, cur = 0, jp[1000005][21], depth[1000005]; struct node { char val; int par; } tree[1000005]; vector<int> pos; void Init() { /* lol who inits amirite */ } void TypeLetter(char L) { tree[cnt] = { L, cur }; jp[cnt][0] = cur; depth[cnt] = depth[cur] + 1; cur = cnt; for (int k = 1; k <= 20; k++) jp[cur][k] = jp[jp[cur][k-1]][k-1]; pos.push_back(cur); cnt++; } void UndoCommands(int U) { int nd = pos[pos.size() - 1 - U]; cur = nd; pos.push_back(cur); } char GetLetter(int P) { int x = depth[cur] - P - 1; int c = cur; for (int k = 20; k >= 0; k--) { if ((x >> k) & 1) c = jp[c][k]; } return tree[c].val; }
#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...