# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
64971 | mhnd | Crayfish scrivener (IOI12_scrivener) | C++14 | 0 ms | 0 KiB |
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 "grader.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6+50;
const ll oo = 1e18;
const ll mod = 1e9+7;
struct node{
char c;
int p[30],sz;
node(){
memset(p,-1,sizeof(p));
sz=0;
}
};
node t[N];
int cur = 0;
void Init() {}
void TypeLetter(char L) {
t[cur].c = L;
t[cur].p[0] = cur-1;
if(cur)t[cur].sz = t[cur-1].sz + 1;
for(int i=1;i<30;i++)t[cur].p[i] = t[t[cur].p[i-1]].p[i-1];
cur++;
}
void UndoCommands(int U) {
t[cur] = t[cur-U-1];
cur++;
}
char GetLetter(int P) {
int u = t[cur-1].sz - P;
int at = cur-1;
for(int k = 29;k>=0;k--)
if((u>>k)&1)
at = t[at].p[k];
return t[at].c;
}