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 pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
const int LOG = 25;
struct Node
{
Node* p[LOG];
int len;
char l;
};
const int MAXN = 1e6 + 5;
int curr = 0;
Node* last[MAXN];
void Init()
{
last[0] = nullptr;
curr = 1;
}
void TypeLetter(char L)
{
last[curr] = new Node();
last[curr] -> l = L;
last[curr] -> len = (last[curr - 1] ? last[curr - 1] -> len : 0) + 1;
last[curr] -> p[0] = last[curr - 1];
for(int i = 1; i < LOG; i++)
last[curr] -> p[i] = nullptr;
for(int i = 1; i < LOG; i++)
if(last[curr] -> p[i - 1] != nullptr)
last[curr] -> p[i] = (last[curr] -> p[i - 1]) -> p[i - 1];
curr++;
}
void UndoCommands(int U)
{
last[curr] = last[curr - U - 1];
curr++;
}
char GetLetter(int P)
{
Node* aux = last[curr - 1];
P = (aux -> len) - P - 1;
for(int i = LOG - 1; i >= 0; i--)
if(P & (1 << i))
aux = (aux -> p[i]);
return (aux -> l);
}
# | 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... |