이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define INIT ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
/*struct node{
char c;
int cnt;
node *l, *r;
node(node *l, node *r){
this->l=l; this->r;
this->cnt=l->cnt+r->cnt;
}
node(char c){
this->c=c;
this->cnt=1;
this->l=NULL;
this->r=NULL;
}
} *ver[1000010];
*/
int tab[1000010][20];
int l[1000010];
char a[1000010];
int Tmp=1;
void add_char(char c){
l[Tmp]=l[Tmp-1]+1;
if(Tmp==1){
a[Tmp]=c;
Tmp++;
return ;
}
a[Tmp]=c;
tab[Tmp][0]=Tmp-1;
for(int j=1; (j<=19) && (tab[Tmp][j-1]>0); j++){
tab[Tmp][j]=tab[tab[Tmp][j-1] ][j-1];
}
Tmp++;
return;
}
void Init() {
}
void TypeLetter(char L) {
add_char(L);
}
void UndoCommands(int U){
for(int j=0; j<=19; j++){tab[Tmp][j]=tab[Tmp-U][j];}
l[Tmp]=l[Tmp-U];
a[Tmp]=a[Tmp-U];
Tmp++;
}
char GetLetter(int P) {
int p=l[Tmp-1]-P+1; p--;
int cr=Tmp-1;
for(int j=19; (j>=0) && (p>0); j--){
if( (p&(1ll<<j))>0 ){
cr=tab[cr][j]; p-=(1ll<<j);
}
}
//cout<<cr<<" ";
//cout<<a[cr]<<"\n";
return a[cr];
}
# | 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... |