제출 #483532

#제출 시각아이디문제언어결과실행 시간메모리
483532dannyboy20031204크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++17
100 / 100
615 ms92996 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 1; char c[N]; int now = 0, idx = 0, d[N], anc[N][21], p[N]; void Init() { now = idx = 0; } void TypeLetter(char L) { idx++; d[idx] = d[now] + 1; anc[idx][0] = now; for (int i = 1; i <= 20; i++) anc[idx][i] = anc[anc[idx][i - 1]][i - 1]; c[idx] = L; p[idx] = idx; now = idx; } void UndoCommands(int U) { idx++; p[idx] = p[idx - U - 1]; now = p[idx]; } char GetLetter(int P) { P++; int u = p[now]; for (int i = 20; i >= 0; i--) if (d[anc[u][i]] >= P) u = anc[u][i]; return c[u]; } /* int main(){ Init(); TypeLetter('a'); TypeLetter('b') ; cout << GetLetter(1) << '\n'; TypeLetter('d'); UndoCommands(2); UndoCommands(1) ; cout << GetLetter(2) << '\n'; TypeLetter('e'); UndoCommands(1); UndoCommands(5) ; TypeLetter('c') ; cout << GetLetter(2) << '\n'; UndoCommands(2); cout << GetLetter(2) << '\n'; } */
#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...