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 <stdio.h>
int rear,cnt;
int par[1000010][22];
int next[1000010];
int many[1000010];
char a[1000010];
void Init(){
rear = cnt = 0;
}
void TypeLetter(char L) {
int i;
rear++; cnt++;
next[cnt] = rear;
a[rear] = L;
par[rear][0] = next[cnt-1];
for(i=1; i<=19; i++){
par[rear][i] = par[par[rear][i-1]][i-1];
}
many[cnt] = many[cnt-1]+1;
}
void UndoCommands(int U) {
cnt++;
next[cnt] = next[cnt-U-1];
many[cnt] = many[cnt-U-1];
}
char GetLetter(int P) {
int i,x;
int ans;
ans = next[cnt];
x = many[cnt]-(P+1);
//printf("%d %d\n",ans,x);
for(i=19; i>=0; i--){
if(x >= (1 << i)){
ans = par[ans][i];
x -= (1 << i);
}
}
return a[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... |