#include <bits/stdc++.h>
using namespace std;
const int LOG = 20;
const int N = 1000000;
int p[N], depth[N];
char letter[N];
int cnt;
char getWord(int x, int P) {
string w;
while (p[x] != x) {
if (letter[x]) w += letter[x];
x = p[x];
}
w += letter[0];
reverse(w.begin(), w.end());
return w[P];
}
void Init() {
cin.tie(0);
ios::sync_with_stdio(false);
cnt = 0;
}
void TypeLetter(char L) {
if (!cnt) {
p[cnt] = 0;
depth[cnt] = 1;
}
else {
p[cnt] = cnt-1;
depth[cnt] = depth[p[cnt]] + 1;
}
letter[cnt] = L;
cnt++;
}
void UndoCommands(int U) {
p[cnt] = cnt - U - 1;
depth[cnt] = depth[p[cnt]]+1;
cnt++;
}
char GetLetter(int P) {
return getWord(cnt-1, 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... |