Submission #416975

#TimeUsernameProblemLanguageResultExecution timeMemory
416975snasibov05Crayfish scrivener (IOI12_scrivener)C++14
60 / 100
1061 ms188724 KiB
#include <vector> #include <string> using namespace std; #define pb push_back const int lg = 25; struct node{ char val; int idx; vector<node*> pr; node(char c){ val = c; idx = 0; pr.resize(25); pr.assign(25, nullptr); } }; string res; vector<node*> v; void Init() {} void TypeLetter(char l) { node* cur = new node(l); if (!v.empty()) { cur->pr[0] = v.back(); cur->idx = cur->pr[0]->idx + 1; } for (int i = 1; i < lg; ++i){ if (cur->pr[i-1] == nullptr) break; cur->pr[i] = cur->pr[i-1]->pr[i-1]; } v.pb(cur); } void UndoCommands(int u) { int n = v.size(); node* cur = v[n - u - 1]; v.pb(cur); } char GetLetter(int p) { node* cur = v.back(); for (int i = lg - 1; i >= 0; --i){ if (cur->pr[i] != nullptr && cur->pr[i]->idx >= p){ cur = cur->pr[i]; } } return cur->val; }
#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...