제출 #425700

#제출 시각아이디문제언어결과실행 시간메모리
425700temurbek_khujaev크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++17
100 / 100
856 ms79324 KiB
#include <bits/stdc++.h> using namespace std; char ans; #define N 1000005 int root[N]; #define prev kfldsj #define next kdslgjdgfs int prev[N]; int next[N]; int up[N][25]; char val[N]; int len[N]; int curr = 1; int last = 0; int next_node = 0; void Init() { } void TypeLetter(char L) { curr++; root[curr] = next_node++; int id = root[curr]; prev[id] = root[curr - 1]; len[id] = len[prev[id]] + 1; val[id] = L; up[id][0] = prev[id]; for (int i = 1; i < 25; i++) { up[id][i] = up[up[id][i - 1]][i - 1]; } } void UndoCommands(int U) { curr++; root[curr] = root[curr - U - 1]; } char GetLetter(int P) { P++; int x = root[curr]; for (int i = 24; i >= 0; i--) { if (len[up[x][i]] >= P) x = up[x][i]; } return val[x]; }
#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...