Submission #439276

#TimeUsernameProblemLanguageResultExecution timeMemory
439276prvocisloCrayfish scrivener (IOI12_scrivener)C++17
60 / 100
1004 ms94012 KiB
#include<bits/stdc++.h> using namespace std; const int maxn = 1e6 + 5, logn = 20; struct cmd { bool undo; int x, sum; char c; }; vector<cmd> v; int jump[logn][maxn]; void NewCommand() // spracuj ten nakonci v ak vies ze musis ist x znakov dozadu { cmd &c = v.back(); int x = c.x + 1; int pv = v.size() - 1 - x; if (pv == -1) return; c.sum += v[pv].sum; if (v[pv].undo) pv = jump[0][pv]; jump[0][v.size() - 1] = pv; for (int i = 1; i < logn; i++) jump[i][v.size() - 1] = jump[i-1][jump[i-1][v.size() - 1]]; } void Init() {} void TypeLetter(char L) { v.push_back({false, 0, 1, L}); NewCommand(); } void UndoCommands(int U) { v.push_back({true, U, 0, '.'}); NewCommand(); } char GetLetter(int P) { int num = v.back().sum, b = num - P; int id = v.size() - 1; if (!v[id].undo) b--; for (int i = 0; i < logn; i++) if ((1 << i) & b) id = jump[i][id]; return v[id].c; }
#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...