제출 #241596

#제출 시각아이디문제언어결과실행 시간메모리
241596johutha크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++17
34 / 100
1067 ms262148 KiB
#include <iostream> #include <vector> #include <cassert> using namespace std; struct node; using node_ptr = node*; struct node { int len; char l; node_ptr upread[21]; node_ptr upundo[21]; node() { l = '0'; len = 0; for (int i = 0; i < 21; i++) { upread[i] = this; upundo[i] = this; } } node(char il, node_ptr lr, node_ptr lu) : l(il) { upread[0] = lr; upundo[0] = lu; len = lr->len + 1; for (int i = 1; i < 21; i++) { upread[i] = (upread[i - 1] != 0 ? upread[i - 1]->upread[i - 1] : node_ptr()); upundo[i] = (upundo[i - 1] != 0 ? upundo[i - 1]->upundo[i - 1] : node_ptr()); } } node_ptr getundo(int k) { node_ptr cp = this; for (int i = 20; i >= 0; i--) { if (k & (1ll<<i)) cp = cp->upundo[i]; assert(cp != 0); } return cp; } node_ptr getread(int k) { node_ptr cp = this; for (int i = 20; i >= 0; i--) { if (k & (1ll<<i)) cp = cp->upread[i]; assert(cp != 0); } return cp; } }; node_ptr back; void Init() { back = new node(); } void TypeLetter(char L) { back = new node(L, back, back); } void UndoCommands(signed U) { node_ptr rep = back->getundo(U); back = new node(rep->l, rep->upread[0], back); } char GetLetter(signed P) { int ind = back->len - 1 - P; node_ptr rd = back->getread(ind); return rd->l; }
#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...