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 mxn = 1e6 + 10;
int nxt[mxn][21], sz[mxn], cnt = 0;
char c[mxn];
void Init() { }
void TypeLetter(char L) {
cnt++;
c[cnt] = L;
sz[cnt] = sz[cnt - 1] + 1;
nxt[cnt][0] = cnt - 1;
for (int i = 1; i <= 20; i++) nxt[cnt][i] = nxt[nxt[cnt][i - 1]][i - 1];
}
void UndoCommands(int U) {
cnt++;
sz[cnt] = sz[cnt - U - 1];
nxt[cnt][0] = nxt[cnt - U - 1][0];
c[cnt] = c[cnt - U - 1];
for (int i = 1; i <= 20; i++) nxt[cnt][i] = nxt[nxt[cnt][i - 1]][i - 1];
}
char GetLetter(int P) {
int len = sz[cnt] - P;
int ans = cnt;
for (int i = 20; i >= 0; i--) {
if (len & (1 << i)) ans = nxt[ans][i];
}
return c[ans];
}
# | 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... |