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;
const int MAXN=1e6+3;
const int LOGN=22;
int cont[MAXN], letra[MAXN];
int dp[MAXN][LOGN+3];
int contv=0;
void update(int cur) {
int aux=dp[cur][0];
for(int i=1; i<=LOGN; i++) {
dp[cur][i]=dp[aux][i-1];
aux=dp[cur][i];
}
}
void Init() {}
void TypeLetter(char cur) {
contv++; int pai=contv-1;
if(pai==0) pai=contv;
letra[contv]=cur;
cont[contv]=cont[pai]+1;
dp[contv][0]=pai;
update(contv);
}
void UndoCommands(int val) {
contv++; int pai=contv-1-val;
if(pai==0) pai=contv;
cont[contv]=cont[pai];
dp[contv][0]=pai;
update(contv);
}
char GetLetter(int ind) {
int cur=contv;
int aux=cur;
while(aux!=dp[aux][0]&&cont[dp[aux][0]]!=ind) aux=dp[aux][0];
return letra[aux];
}
# | 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... |