제출 #416982

#제출 시각아이디문제언어결과실행 시간메모리
416982snasibov05크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++14
100 / 100
950 ms90708 KiB
#include <vector> #include <string> using namespace std; #define pb push_back const int lg = 20; //vector<node*> v; vector<int> idx; vector<char> val; vector<vector<int>> pr; vector<int> v; int k = 1; void Init() { v.pb(0); idx.pb(-1); val.pb(' '); pr.pb(vector<int>(lg, -1)); } void TypeLetter(char l) { int prev = v.back(); v.pb(k++); idx.pb(idx[prev] + 1); val.pb(l); pr.pb(vector<int>(lg)); if (prev == 0) prev = -1; pr.back()[0] = prev; for (int i = 1; i < lg; ++i){ if (pr.back()[i-1] == -1) break; pr.back()[i] = pr[pr.back()[i-1]][i-1]; } } void UndoCommands(int u) { int n = v.size(); int cur = v[n - u - 1]; v.pb(cur); } char GetLetter(int p) { int cur = v.back(); for (int i = lg - 1; i >= 0; --i){ if (pr[cur][i] != -1 && idx[pr[cur][i]] >= p){ cur = pr[cur][i]; } } return val[cur]; }
#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...