# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
751973 | minhcool | 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.
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
const int N = 1e6 + 5;
const int oo = 1e18 + 7, mod = 1e9 + 7;
mt19937 rng(1);
int n;
void init(){}
int cnt;
int lst[N][25], len[N];
char cc[N];
void typeletter(char c){
cnt++;
len[cnt] = len[cnt - 1] + 1;
cc[cnt] = c;
lst[cnt][0] = cnt - 1;
for(int i = 1; i <= 20; i++) lst[cnt][i] = lst[lst[cnt][i - 1]][i - 1];
}
void UndoCommands(int x){
cnt++;
len[cnt] = len[cnt - x - 1];
//lst[cnt][0] = lst[cnt - x - 1][0];
cc[cnt] = cc[cnt - x - 1];
for(int i = 0; i <= 20; i++) lst[cnt][i] = lst[cnt - x - 1][i];
}
char getLetter(int x){
x++;
int temp = cnt - x;
int pos = cnt;
for(int i = 20; i >= 0; i--) if(temp & (1LL << i)) pos = lst[pos][i];
return cc[pos];
}