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;
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//#undef LOCALKL
#define IO \
ios_base::sync_with_stdio(0);(cin).tie(0);(cout).tie(0)
#define y1 y1_
#define prev prev_
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#ifdef LOCALKL
// #define cerr cerr<<"\33[1;32m"
// #define cout cout<<"\33[0m"
#else
#ifndef OO
#define endl '\n'
#define cerr if(1){}else cerr
#endif
#endif
#define OK cout<<"OK\n"<<endl;
#define setpre(k) fixed<<setprecision(k)
#define mmset(k,y) memset(k,y,sizeof(k))
#define sz(x) ((int)(x).size())
using pii = pair<int,int>;
using pll = pair<long long,long long>;
using ull = unsigned long long;
using intt = long long;
using ll = long long;
using ld = long double;
const ll m9 = 998244353;
const ll m7 = 1000000007;
const ll m18 = 1000000000000000000;
const ll i127 = 2193062143;
const ll l127 = 9187201950435737471;
struct letter
{
char x;
int sz=0;
int pos[21];
};
letter a[1000001];
int pos = 1;
void Init(){}
void TypeLetter(char L)
{
a[pos].pos[0] = pos-1;
for(int i=1;i<=20;i++)
a[pos].pos[i] = a[a[pos].pos[i-1]].pos[i-1];
a[pos].x = L;
//cerr<<" > "<<pos<<' '<<L<<endl;
a[pos].sz = a[pos-1].sz+1;
pos++;
}
void UndoCommands(int U)
{
a[pos] = a[pos-U-1];
pos++;
}
char GetLetter(int P)
{
int k = a[pos-1].sz-P-1;
int poss = pos-1;
//cerr<<" <> "<<poss<<' '<<k<<endl;
for(int i=20;i>=0;i--)
if((1<<i)<=k)
{
//cerr<<" >>> P "<<poss<<endl;
k-=1<<i;
poss=a[poss].pos[i];
}
//cerr<<" Print "<<poss<<endl;
return a[poss].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... |