#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;
char letter[1000005];
int Len[1000005],pa[20][1000005],ti[1000005],lg=18,t;
void Init(){
t=0,Len[0]=-1;
}
void TypeLetter(char L)
{
++t,ti[t]=t,Len[t]=Len[ti[t-1]]+1,letter[t]=L;
pa[0][t]=ti[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]=ti[t-U-1],Len[t]=Len[t-U-1];
}
char GetLetter(int P)
{
int x=ti[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];
return letter[x];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
512 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
2 ms |
512 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
2 ms |
512 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Correct |
2 ms |
512 KB |
Output is correct |
10 |
Correct |
2 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
512 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
2 ms |
512 KB |
Output is correct |
6 |
Correct |
2 ms |
512 KB |
Output is correct |
7 |
Correct |
2 ms |
512 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Correct |
2 ms |
512 KB |
Output is correct |
10 |
Correct |
2 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
640 KB |
Output is correct |
2 |
Correct |
3 ms |
768 KB |
Output is correct |
3 |
Correct |
3 ms |
896 KB |
Output is correct |
4 |
Correct |
3 ms |
896 KB |
Output is correct |
5 |
Correct |
3 ms |
768 KB |
Output is correct |
6 |
Correct |
3 ms |
896 KB |
Output is correct |
7 |
Correct |
3 ms |
896 KB |
Output is correct |
8 |
Correct |
3 ms |
896 KB |
Output is correct |
9 |
Correct |
4 ms |
896 KB |
Output is correct |
10 |
Correct |
3 ms |
896 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
401 ms |
60132 KB |
Output is correct |
2 |
Correct |
455 ms |
73208 KB |
Output is correct |
3 |
Correct |
348 ms |
72652 KB |
Output is correct |
4 |
Correct |
367 ms |
76180 KB |
Output is correct |
5 |
Correct |
537 ms |
67456 KB |
Output is correct |
6 |
Correct |
330 ms |
79352 KB |
Output is correct |
7 |
Correct |
625 ms |
67928 KB |
Output is correct |
8 |
Correct |
437 ms |
76548 KB |
Output is correct |
9 |
Correct |
508 ms |
73592 KB |
Output is correct |
10 |
Correct |
213 ms |
82808 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
763 ms |
55316 KB |
Output is correct |
2 |
Execution timed out |
1076 ms |
47572 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |