# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
911514 | Sir_Ahmed_Imran | Crayfish scrivener (IOI12_scrivener) | C++17 | 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.
///~~~LOTA~~~///
#include "scrivener.h"
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define ff first
#define ss second
#define ll long long
#define append push_back
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define N 1000001
int c;
struct node{
int ind;
char val;
node* par[20];
};
node* x[N];
void Init(){
c=0;
x[0]=new node();
x[0]->ind=-1;
for(int i=0;i<20;i++)
x[0]->par[i]=x[0];
}
void TypeLetter(char L){
c++;
x[c]=new node();
x[c]->ind=x[c-1]->ind+1;
x[c]->par[0]=x[c-1];
x[c]->val=L;
for(int i=0;i<19;i++)
x[c]->par[i+1]=(x[c]->par[i])->par[i];
}
void UndoCommands(int U){
c++;
x[c]=new node;
x[c]->par[0]=x[c-U-1];
x[c]->ind=x[c]->par[0]->ind;
for(int i=0;i<19;i++)
x[c]->par[i+1]=x[c]->par[i]->par[i];
}
char GetLetter(int P){
node* n=x[c];
for(int i=19;i>=0;i--){
if(n->par[i]->ind>=P){
cout<<i<<' '<<n->par[i]->ind<<nl;
n=n->par[i];
}
}
return n->val;
}