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>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
pair<char,int> A[1000002];
int te=1,X;
int p[19][1000002],ii;
void Init()
{
A[0].se=-1;
//for(ii=1;ii<=1000002;ii++)
// LO[ii]=ceil(log(ii)/log(2));
}
void TypeLetter(char L)
{
A[te]=mp(L,A[te-1].se+1);
p[0][te]=te-1;
for(ii=1;ii<19;ii++)
p[ii][te]=p[ii-1][p[ii-1][te]];
te++;
}
void UndoCommands(int U)
{
A[te]=A[te-U-1];
// p[0][te]=p[0][te-U-1];
// for(ii=1;ii<19;ii++)
// p[ii][te]=p[ii-1][p[ii-1][te]];
for(ii=0;ii<19;ii++)
p[ii][te]=p[ii][te-U-1];
te++;
}
char GetLetter(int P)
{
X=te-1;
for(ii=18;ii>=0;ii--)
if(A[p[ii][X]].se>P)
X=p[ii][X];
else
if(A[p[ii][X]].se==P)
return A[p[ii][X]].fi;
return A[X].fi;
}
# | 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... |