Submission #197030

#TimeUsernameProblemLanguageResultExecution timeMemory
197030dennisstarCrayfish scrivener (IOI12_scrivener)C++11
34 / 100
718 ms262144 KiB
#include <bits/stdc++.h> #define fi first #define se second #define ryan bear #define all(V) (V).begin(), (V).end() #define unq(V) (V).erase(unique(all(V)), (V).end()) #define fastio ios::sync_with_stdio(false); cin.tie(0) using namespace std; typedef long long ll; typedef vector<ll> vlm; typedef vector<int> vim; typedef pair<ll, ll> pll; typedef pair<int, int> pii; struct node { char ch; node *l, *r; node() { ch=0; l=r=NULL; } }*root[1000010]; int sz[1000010], tp; void upd(node *now, node *nd, int t, int s, int e, char val) { if (s==e) { now->ch=val; return ; } int md=(s+e)/2; if (t<=md) { now->l=new node(); now->r=(nd?nd->r:NULL); upd(now->l, nd?nd->l:NULL, t, s, md, val); } else { now->l=(nd?nd->l:NULL); now->r=new node(); upd(now->r, nd?nd->r:NULL, t, md+1, e, val); } } char get(node *now, int t, int s, int e) { if (s==e) return now->ch; int md=(s+e)/2; if (t<=md) return get(now->l, t, s, md); else return get(now->r, t, md+1, e); } void Init() { root[0]=new node(); tp=1; memset(sz, 0, sizeof(sz)); } void TypeLetter(char L) { root[tp]=new node(); sz[tp]=sz[tp-1]+1; upd(root[tp], root[tp-1], sz[tp], 1, 1000000, L); tp++; } void UndoCommands(int U) { assert(tp-U-1>=0); root[tp]=root[tp-U-1]; sz[tp]=sz[tp-U-1]; tp++; } char GetLetter(int P) { assert(sz[tp-1]>=P+1); return get(root[tp-1], P+1, 1, 1000000); }
#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...