This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> stac;
void Init() {
vector<int> initial(23, 0);
stac.push_back(initial);
}
void TypeLetter(char L) {
int x = stac.size();
vector<int> newstac;
newstac.push_back(stac[x-1][0]+1);
newstac.push_back(L-'a');
newstac.push_back(x-1);
for (int i=3; i<=22; i++)
newstac.push_back(stac[x-1][i-1]);
stac.push_back(newstac);
}
void UndoCommands(int U) {
int curr = stac.size() - 1;
stac.push_back(stac[curr-U]);
}
char GetLetter(int P) {
int height = stac.size();
int text_length = stac[height-1][0];
int akyat = text_length-1-P;
int curr = height-1;
for (int i=20; i>=0; i--)
{
if (akyat>=(1<<i))
{
akyat -= (1<<i);
curr = stac[curr][i+2];
}
}
char ans = ('a'+stac[curr][1]);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |