This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
#pragma GCC target ("avx2")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int LOG=20,MX=(int)(1e6+7);
int up[MX][LOG],d[MX],idx;
char car[MX];
vector<int> vec[MX];
void Init() {
}
void TypeLetter(char L) {
vec[idx].pb(idx+1);
d[idx+1]=d[idx]+1;
up[idx+1][0]=idx;
for (int i = 1; i < LOG; ++i)
up[idx+1][i]=up[up[idx+1][i-1]][i-1];
car[idx+1]=L;
idx++;
}
void UndoCommands(int U) {
d[idx+1]=d[idx-U];
up[idx+1][0]=up[idx-U][0];
for (int i = 1; i < LOG; ++i)
up[idx+1][i]=up[up[idx+1][i-1]][i-1];
if(idx!=U){
vec[up[idx-U][0]].pb(idx+1);
car[idx+1]=car[idx-U];
}
idx++;
}
char GetLetter(int P) {
int k=d[idx]-1-P,a=idx;
for (int i = 0; i < LOG; ++i)
if((k>>i)&1)a=up[a][i];
return car[a];
}
# | 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... |