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;
#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#ifdef MPS
#define D(x...) printf(x)
#else
#define D(x...)
#endif
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;
void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}
const int maxn = 1000005;
struct node{int dep, fa[21]; char c;}a[maxn];
int T;
void Init()
{
T = 0;
}
void TypeLetter(char L)
{
++ T;
a[T].dep = a[T-1].dep + 1;
a[T].fa[0] = T-1; fo(j,1,20) a[T].fa[j] = a[a[T].fa[j-1]].fa[j-1];
a[T].c = L;
}
void UndoCommands(int U)
{
++ T; a[T] = a[T-1-U];
}
char GetLetter(int P)
{
int c = a[T].dep - P - 1, now = T;
fd(i,20,0) if(c&(1<<i)) now = a[now].fa[i];
return a[now].c;
}
# | 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... |