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 <vector>
#include <iostream>
using namespace std;
int curr;
int len[1000001];
char last[1000001];
int letter_anc[20][1000001];
void Init()
{
curr = 0;
len[0] = -1;
last[0] = '?';
for(int e = 0; e < 20; e++)
letter_anc[e][0] = 0;
}
void TypeLetter(char L)
{
curr++;
len[curr] = len[curr-1] + 1;
last[curr] = L;
letter_anc[0][curr] = curr-1;
for(int e = 1; e < 20; e++)
{
letter_anc[e][curr] = letter_anc[e-1][ letter_anc[e-1][curr] ];
}
// cerr << curr << '\n';
}
void UndoCommands(int U)
{
int prev = curr - U;
// cerr << "making copy of " << prev << '\n';
curr++;
len[curr] = len[prev];
last[curr] = last[prev];
letter_anc[0][curr] = letter_anc[0][prev];
for(int e = 1; e < 20; e++)
{
letter_anc[e][curr] = letter_anc[e-1][ letter_anc[e-1][curr] ];
}
// cerr << curr << '\n';
}
char GetLetter(int P)
{
int pos = curr;
for(int e = 19; e >= 0; e--)
if(len[ letter_anc[e][pos] ] >= P)
pos = letter_anc[e][pos];
return last[pos];
}
# | 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... |