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<iostream>
using namespace std;
const int LIM=1e6+7, LG=20;
int ile[LIM], nxt[LIM][LG], sum[LIM][LG], akt;
char V[LIM];
void licz() {
for(int i=1; i<LG; ++i) {
nxt[akt][i]=nxt[nxt[akt][i-1]][i-1];
}
}
void Init() {}
void TypeLetter(char x) {
++akt;
V[akt]=x;
ile[akt]=ile[akt-1]+1;
if(V[akt-1]=='0') nxt[akt][0]=nxt[akt-1][0];
else nxt[akt][0]=akt-1;
licz();
}
void UndoCommands(int x) {
++akt;
V[akt]='0';
ile[akt]=ile[akt-x-1];
if(V[akt-x-1]=='0') nxt[akt][0]=nxt[akt-x-1][0];
else nxt[akt][0]=akt-x-1;
licz();
}
char GetLetter(int x) {
x=ile[akt]-x;
if(V[akt]!='0') --x;
int p=akt;
for(int i=0; i<LG; ++i) if(x&(1<<i)) p=nxt[p][i];
return V[p];
}
# | 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... |