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;
char s[1000001];
int now = 0, i = 1, dir[1000001][21], sz[1000001];
void Init() {}
int find(int i, int x){
for(int j = 0; j < 21; j++){
if((1 << j) & x){
i = dir[i][j];
}
}
return i;
}
void TypeLetter(char L) {
s[i] = L;
dir[i][0] = now;
sz[i] = sz[now] + 1;
dir[i][0] = now;
for(int j = 1; j < 21; j++){
if(sz[i] <= (1 << j)) break;
dir[i][j] = dir[dir[i][j - 1]][j - 1];
}
now = i;
i++;
}
void UndoCommands(int U) {
now = i - U - 1;
s[i] = s[now];
for(int j = 0; j <= 20; j++)dir[i][j] = dir[now][j];
sz[i] = sz[now];
i++;
}
char GetLetter(int P) {
return s[find(i - 1, sz[i - 1] - P - 1)];
}
# | 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... |