이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include"bits/stdc++.h"
//#include"scrivener.h"
#define overload(a,b,c,d,...) d
#define rep1(a) for(ll _=0;_<(ll)a;++_)
#define rep2(i,a) for(ll i=0;i<(ll)(a);++i)
#define rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) overload(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__)
#define rrep1(i,a) for(ll i=(ll)(a)-1;i>=0;--i)
#define rrep2(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);--i)
#define rrep(...) overload(__VA_ARGS__,rrep2,rrep1)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
using namespace std;
using ll=long long;
using ull=unsigned long long;
using i128=__int128_t;
using ld=long double;
using vi=vector<int>;
using vl=vector<ll>;
template<typename T,typename U>inline bool chmin(T&a,const U&b){return (a>b?a=b,true:false);}
template<typename T,typename U>inline bool chmax(T&a,const U&b){return (a<b?a=b,true:false);}
struct Node{
int val;
int sz;
int table[20]={};
Node(){
sz=0,val=-1;
rep(i,20)table[i]=0;
}
};
Node nodes[2000000];
int idx;
void Init() {
idx=1;
nodes[0]=Node();
}
void TypeLetter(char L) {
nodes[idx]=Node();
nodes[idx].val=L-'a';
nodes[idx].sz=nodes[idx-1].sz+1;
nodes[idx].table[0]=idx-1;
rep(i,1,20)nodes[idx].table[i]=nodes[nodes[idx].table[i-1]].table[i-1];
idx++;
}
void UndoCommands(int U) {
//cerr<<"Undo Commands "<<U<<endl;
nodes[idx]=nodes[idx-1-U];
idx++;
//cerr<<sz<<endl;
}
char GetLetter(int P) {
//cerr<<"Get Letter "<<P<<endl;
int now=idx-1;
rrep(i,20){
if(nodes[nodes[now].table[i]].sz>=P+1){
now=nodes[now].table[i];
}
}
return nodes[now].val+'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... |