Submission #314023

#TimeUsernameProblemLanguageResultExecution timeMemory
314023joseacaz크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++17
100 / 100
787 ms166776 KiB
#include <bits/stdc++.h> #define pb push_back #define all(x) x.begin(), x.end() using namespace std; using ll = long long; using vi = vector<int>; using vl = vector<ll>; const int LOG = 25; struct Node { Node* p[LOG]; int len; char l; }; const int MAXN = 1e6 + 5; int curr = 0; Node* last[MAXN]; void Init() { last[0] = nullptr; curr = 1; } void TypeLetter(char L) { last[curr] = new Node(); last[curr] -> l = L; last[curr] -> len = (last[curr - 1] ? last[curr - 1] -> len : 0) + 1; last[curr] -> p[0] = last[curr - 1]; for(int i = 1; i < LOG; i++) last[curr] -> p[i] = nullptr; for(int i = 1; i < LOG; i++) if(last[curr] -> p[i - 1] != nullptr) last[curr] -> p[i] = (last[curr] -> p[i - 1]) -> p[i - 1]; curr++; } void UndoCommands(int U) { last[curr] = last[curr - U - 1]; curr++; } char GetLetter(int P) { Node* aux = last[curr - 1]; P = (aux -> len) - P - 1; for(int i = LOG - 1; i >= 0; i--) if(P & (1 << i)) aux = (aux -> p[i]); return (aux -> 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...