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 <iostream>
#include <vector>
#include <string>
using namespace std;
const int MAXN = 1e6;
int t[MAXN+1][20], len[MAXN+1];
int pos = 0;
char letter[MAXN+1];
void Init() {}
void TypeLetter(char L) {
letter[++pos] = L;
len[pos] = len[pos-1] + 1;
t[pos][0] = pos - 1;
for (int b = 1; b < 20; b++) {
t[pos][b] = t[t[pos][b-1]][b-1];
}
}
void UndoCommands(int U) {
letter[++pos] = ' ';
len[pos] = len[pos - U - 1];
t[pos][0] = pos - U - 1;
for (int b = 1; b < 20; b++) {
t[pos][b] = t[t[pos][b-1]][b-1];
}
}
char GetLetter(int P) {
int cur = pos;
P++;
for (int b = 19; b >= 0; b--) {
if (len[t[cur][b]] >= P) {
cur = t[cur][b];
}
}
return letter[cur];
}
void OutputLogs() {}
# | 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... |