Submission #118534

#TimeUsernameProblemLanguageResultExecution timeMemory
118534PlurmCrayfish scrivener (IOI12_scrivener)C++11
34 / 100
349 ms151464 KiB
#include <bits/stdc++.h> using namespace std; const int MXN = 1 << 20; const int COEFF = 8; char mem[COEFF*MXN]; int llink[COEFF*MXN]; int rlink[COEFF*MXN]; int root; int nodesz; vector<int> rootlist; vector<int> lens; inline int newnode(int o = -1){ int c = ++nodesz; if(o != -1){ llink[c] = llink[o]; rlink[c] = rlink[o]; mem[c] = mem[o]; } return c; } inline int build(int l, int r){ int c = newnode(); if(l == r) return c; int k = (l+r)/2; llink[c] = build(l,k); rlink[c] = build(k+1,r); return c; } inline int update(int o, int idx, char upd, int lb, int rb){ int c = newnode(o); if(lb == rb){ mem[c] = upd; return c; } int k = (lb + rb)/2; if(idx <= k){ llink[c] = update(llink[c], idx, upd, lb, k); }else{ rlink[c] = update(rlink[c], idx, upd, k+1, rb); } return c; } inline char query(int c, int idx, int lb, int rb){ if(lb == rb) return mem[c]; int k = (lb + rb)/2; if(idx <= k) return query(llink[c], idx, lb, k); else return query(rlink[c], idx, k+1, rb); } void Init() { root = build(0, MXN-1); rootlist.push_back(root); lens.push_back(0); } void TypeLetter(char L) { int l = lens.back(); int o = rootlist.back(); int c = update(o, l, L, 0, MXN-1); rootlist.push_back(c); lens.push_back(l+1); } void UndoCommands(int U) { int vn = rootlist.size() - 1 - U; lens.push_back(lens[vn]); rootlist.push_back(rootlist[vn]); } char GetLetter(int P) { return query(rootlist.back(), P, 0, MXN-1); }
#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...