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 FIXED_FLOAT(x) std::fixed <<std::setprecision(20) << (x)
#define all(v) (v).begin(), (v).end()
using namespace std;
#define forn(i,n) for (int i = 0; i < (n); ++i)
#define rforn(i, n) for(int i = (n) - 1;i >= 0;--i)
using ll = long long;
int mod = (ll)1e9 + 7;
#define PI acos(-1)
typedef pair<int, int> pairs;
const int INF = 1e9 + 1;
const int N = 1e6 + 3;
const double eps = 1e-7;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <typename XPAX>
void ckma(XPAX &x, XPAX y) {
x = (x < y ? y : x);
}
template <typename XPAX>
void ckmi(XPAX &x, XPAX y) {
x = (x > y ? y : x);
}
int head[N], len[N], cur, nxt, com;
int pre[N][20];
char last[N];
void Init() {
cur = nxt = 0;
head[0] = 0;
com = 0;
forn(i, 20) pre[0][i] = 0;
++nxt;
}
void TypeLetter(char L) {
len[nxt] = len[cur] + 1;
last[nxt] = L;
int x = cur;
forn(i, 20) {
pre[nxt][i] = x;
x = pre[x][i];
}
head[++com] = cur = nxt++;
}
void UndoCommands(int U) {
com++;
head[com] = cur = head[com - U - 1];
}
char GetLetter(int P) {
int dx = len[cur] - P - 1;
int u = cur;
forn(i, 20) if(dx >> i & 1) u = pre[u][i];
return last[u];
}
# | 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... |