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 <string>
struct String{
int len;
char last;
int prev[20];
String():len(0),last('\0'){
}
}str[1000001];
int curr=0;
void Init() {}
void TypeLetter(char L) {
str[curr+1].len=str[curr].len+1;
str[curr+1].last=L;
str[curr+1].prev[0]=curr;
for(int k=1;k<20;k++){
str[curr+1].prev[k]=str[str[curr+1].prev[k-1]].prev[k-1];
}
curr++;
}
void UndoCommands(int U) {
str[curr+1]=str[curr-U];
curr++;
}
char GetLetter(int P) {
int move=str[curr].len-1-P;
int x=curr;
for(int k=0;k<20;k++){
if(move&(1<<k)){
x=str[x].prev[k];
}
}
return str[x].last;
}
# | 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... |