제출 #1054610

#제출 시각아이디문제언어결과실행 시간메모리
1054610onbert크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++17
34 / 100
323 ms262144 KiB
#include <bits/stdc++.h> using namespace std; struct node { char val; int lpt, rpt; }; const int maxn = 1e6, maxN = 4e6 + 10; vector<node> seg[maxN]; vector<int> sz = {0}; void build(int id, int l, int r) { seg[id] = {{'.', 0, 0}}; if (l==r) return; int mid = (l+r)/2; build(id*2, l, mid); build(id*2+1, mid+1, r); } void update(int id, int pt, int l, int r, int target, char val) { if (l==r) { seg[id].push_back({val, 0, 0}); return; } int mid = (l+r)/2; seg[id].push_back(seg[id][pt]); if (l<=target && target<=mid) { update(id*2, seg[id][pt].lpt, l, mid, target, val); seg[id].back().lpt = (int)seg[id*2].size() - 1; } else { update(id*2+1, seg[id][pt].rpt, mid+1, r, target, val); seg[id].back().rpt = (int)seg[id*2+1].size() - 1; } } char qry(int id, int pt, int l, int r, int target) { if (r<target || target<l) return '.'; if (l==r) return seg[id][pt].val; int mid = (l+r)/2; return max(qry(id*2, seg[id][pt].lpt, l, mid, target), qry(id*2+1, seg[id][pt].rpt, mid+1, r, target)); } void Init() { build(1, 0, maxn); } void TypeLetter(char L) { // cout << L << " " << (int)seg[1].size()-1 << endl; update(1, (int)seg[1].size()-1, 0, maxn, sz.back(), L); sz.push_back(sz.back() + 1); } void UndoCommands(int U) { seg[1].push_back(seg[1][(int)seg[1].size() - U - 1]); sz.push_back(sz[(int)sz.size() - U - 1]); } char GetLetter(int P) { return qry(1, (int)seg[1].size() - 1, 0, maxn, P); }
#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...