제출 #241598

#제출 시각아이디문제언어결과실행 시간메모리
241598johutha크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++17
100 / 100
565 ms90616 KiB
#include <iostream> #include <vector> #include <cassert> using namespace std; int upr[1000001][21]; char ch[1000001]; int len[1000001]; int cnt = 0; void Init() { cnt = 1; for (int i = 0; i < 21; i++) upr[0][i] = 0; } void TypeLetter(char L) { ch[cnt] = L; len[cnt] = len[cnt - 1] + 1; upr[cnt][0] = cnt - 1; for (int i = 1; i < 21; i++) upr[cnt][i] = upr[upr[cnt][i - 1]][i - 1]; cnt++; } void UndoCommands(signed U) { int st = cnt - U - 1; ch[cnt] = ch[st]; for (int i = 0; i < 21; i++) upr[cnt][i] = upr[st][i]; len[cnt] = len[st]; cnt++; } char GetLetter(signed P) { int u = len[cnt - 1] - 1 - P; int c = cnt - 1; for (int i = 0; i < 21; i++) { if (u & (1<<i)) { c = upr[c][i]; } } return ch[c]; }
#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...