제출 #224216

#제출 시각아이디문제언어결과실행 시간메모리
224216staniewzki크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++17
100 / 100
973 ms124144 KiB
#include<bits/stdc++.h> using namespace std; #define REP(i, n) for(int i = 0; i < n; i++) #define FOR(i, a, b) for(int i = a; i <= b; i++) #define ST first #define ND second ostream& operator<<(ostream &out, string str) { for(char c : str) out << c; return out; } template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) { return out << "(" << p.ST << ", " << p.ND << ")"; } template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) { out << "{"; for(auto it = a.begin(); it != a.end(); it = next(it)) out << (it != a.begin() ? ", " : "") << *it; return out << "}"; } void dump() { cerr << "\n"; } template<class T, class... Ts> void dump(T a, Ts... x) { cerr << a << ", "; dump(x...); } #ifdef DEBUG # define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__) #else # define debug(...) false #endif template<class T> int size(T && a) { return (int) a.size(); } using LL = long long; using PII = pair<int, int>; vector<vector<int>> jump; vector<char> label; vector<int> dep; int get_ptr(int v, int q) { if(q < size(jump[v])) return jump[v][q]; return -1; } int add_vertex(char c, int p) { label.emplace_back(c); if(p != -1) dep.emplace_back(dep[p] + 1); else dep.emplace_back(-1); jump.emplace_back(); auto &j = jump.back(); while(p != -1) { j.emplace_back(p); p = get_ptr(p, size(j) - 1); } return size(label) - 1; } vector<int> pos; void Init() { pos.emplace_back(add_vertex(0, -1)); } void TypeLetter(char L) { int last = pos.back(); pos.emplace_back(add_vertex(L, last)); } void UndoCommands(int U) { int s = size(pos) - 1; pos.emplace_back(pos[s - U]); } char GetLetter(int P) { int q = 0, v = pos.back(); int k = dep[v] - P; while(k) { if(k % 2) v = get_ptr(v, q); k /= 2, q++; } return label[v]; }
#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...