제출 #483522

#제출 시각아이디문제언어결과실행 시간메모리
483522dannyboy20031204크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++17
60 / 100
1020 ms90548 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e6; char c[N]; int now = 0, idx = 0, d[N], anc[N][21]; 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; now = idx; } void UndoCommands(int U) { idx++; int p = idx - U - 1; d[idx] = d[p]; anc[idx][0] = p; for (int i = 1; i <= 20; i++) anc[idx][i] = anc[anc[idx][i - 1]][i - 1]; now = idx; } char GetLetter(int P) { P++; int u = 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...