이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define ET cout << "\n"
#define MEM(i,j) memset(i,j,sizeof i)
#define F first
#define S second
#define MP make_pair
#define ALL(v) v.begin(),v.end()
#define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
vector<vector<pair<int,char>>> v(1000005,vector<pair<int,char>>());
int Len[1000005],pa[20][1000005],ti[1000005],lg=19,t;
void Init(){
t=0,Len[0]=-1;
}
int finds(int x)
{
if(ti[x]==x) return x;
return ti[x]=finds(ti[x]);
}
void TypeLetter(char L)
{
++t,ti[t]=t,Len[t]=Len[finds(t-1)]+1,v[Len[t]].pb(MP(t,L));
pa[0][t]=finds(t-1);
for(int i=1;i<=lg;++i)
pa[i][t]=pa[i-1][pa[i-1][t]];
}
void UndoCommands(int U)
{
++t,ti[t]=finds(t-U-1),Len[t]=Len[finds(t-U-1)];
}
char GetLetter(int P)
{
int x=finds(t);
for(int i=__lg(t);i>=0;--i)
if(Len[pa[i][x]]>=P)
x=pa[i][x];
if(Len[pa[0][x]]>=P)
x=pa[0][x];
auto p=lower_bound(ALL(v[P]),MP(x,'a'));
return p->S;
}
| # | 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... |