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=1000005;
int N, nod, now, cmd;
int spt[MAXN][21], A[MAXN], L[MAXN];
char let[MAXN];
void Init() {}
void TypeLetter(char c) {
int i, p;
A[++cmd]=now;
let[++nod]=c;
L[nod]=L[now]+1;
spt[nod][0]=now;
now=nod;
for(i=1, p=now; ; i++){
if(spt[spt[p][i-1]][i-1]==0) break;
spt[p][i]=spt[spt[p][i-1]][i-1];
}
}
void UndoCommands(int U) {
A[++cmd]=now;
now=A[cmd-U];
}
char GetLetter(int P) {
int i, p=now, q=L[now]-P-1;
for(i=20; i>=0; i--)if((1<<i)&q){
p=spt[p][i];
}
return let[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... |