제출 #62570

#제출 시각아이디문제언어결과실행 시간메모리
62570zetapi크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++14
100 / 100
770 ms92456 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1000005; int cur; int cnt1, cnt2; int h[N]; int par[20][N]; int arr[N]; char a[N]; void Init() {} void TypeLetter(char L) { ++cnt1; par[0][cnt1] = cur, h[cnt1] = h[cur] + 1; cur = cnt1, a[cur] = L; for (int i = 1; i < 20; ++i) { par[i][cur] = par[i - 1][par[i - 1][cur]]; } arr[++cnt2] = cur; } void UndoCommands(int U) { cur = arr[cnt2 + 1] = arr[cnt2 - U]; ++cnt2; } char GetLetter(int P) { int pos = cur; int H = h[cur] - (P + 1); for (int i = 19; i >= 0; --i) { if (H >= (1 << i)) { H -= (1 << i), pos = par[i][pos]; } } return a[pos]; }
#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...