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>
#define prev Prev
using namespace std;
const int N = 1000005;
int id, c[N][25], prev[N], len[N];
vector<char> s;
void Init() {
s.push_back('0');
}
void TypeLetter(char L) {
id++;
c[id][0] = id;
s.push_back(L);
len[id] = len[id - 1] + 1;
prev[id] = c[id - 1][0];
for(int i = 1; i < 20; i++) {
c[id][i] = c[prev[c[id][i - 1]]][i - 1];
}
}
void UndoCommands(int U) {
++id; s.push_back('0');
int x = id - U - 1;
len[id] = len[x];
for(int i = 0; i < 20; i++) c[id][i] = c[x][i];
}
char GetLetter(int P) {
int x = c[id][0];
P = len[id] - P;
for(int i = 20 - 1; i >= 0; i--) {
if((1 << i) < P) x = prev[c[x][i]], P -= 1 << i;
}
return s[c[x][0]];
}
# | 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... |