제출 #65745

#제출 시각아이디문제언어결과실행 시간메모리
65745aquablitz11크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++14
0 / 100
1097 ms263168 KiB
#include <bits/stdc++.h> using namespace std; const int n = 1e6; struct node { char c; node *l, *r; node(char c) : c(c), l(0), r(0) {} node(node *l, node *r) : c(0), l(l), r(r) {} }; node *build(int b=0, int e=n-1) { if (b == e) return new node(0); int m = (b+e)/2; return new node(build(b, m), build(m+1, e)); } node *update(int i, char c, node *p, int b=0, int e=n-1) { if (b==e) return new node(c); int m = (b+e)/2; if (i <= m) return new node(update(i, c, p->l, b, m), p->r); else return new node(p->l, update(i, c, p->r, m+1, e)); } char get(int i, node *p, int b=0, int e=n-1) { if (b == e) return p->c; int m = (b+e)/2; if (i <= m) return get(i, p->l, b, m); else return get(i, p->r, m+1, e); } const int V = 1e6+1; int vc = 0; int len[V]; node *ptr[V]; void Init() { printf("Init()\n"); len[0] = 0; ptr[0] = build(); } void TypeLetter(char L) { printf("TypeLetter(%c)\n", L); ++vc; len[vc] = len[vc-1]+1; ptr[vc] = update(len[vc-1], L, ptr[vc-1]); } void UndoCommands(int U) { printf("UndoCommands(%d)\n", U); U = min(U, vc); ++vc; len[vc] = len[vc-U-1]; ptr[vc] = ptr[vc-U-1]; } char GetLetter(int P) { char ans = get(P, ptr[vc]); printf("GetLetter(%d) = %c\n", P, ans); return ans; }
#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...