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;
#define m_p make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
typedef long long ll;
const int N = 1000006, m = 20;
int z;
char a[N];
int p[N][m];
int d[N];
vector<int> v;
void Init()
{
v.push_back(0);
}
void TypeLetter(char L)
{
++z;
a[z] = L;
p[z][0] = v.back();
d[z] = d[v.back()] + 1;
for (int i = 1; i < m; ++i)
p[z][i] = p[p[z][i - 1]][i - 1];
v.push_back(z);
}
void UndoCommands(int U)
{
v.push_back(v[sz(v) - U - 1]);
}
char GetLetter(int P)
{
++P;
int x = v.back();
for (int i = m - 1; i >= 0; --i)
{
if (d[p[x][i]] >= P)
x = p[x][i];
}
return a[x];
}
# | 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... |