#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
char last;
pair<int,int> A[1010101];
int te,X;
int p[22][1000001];
int LO[1000005],ii;
void Init()
{
for(ii=1;ii<=1000002;ii++)
LO[ii]=ceil(log(ii)/log(2));
}
void TypeLetter(char L)
{
if(te==0)
A[te]=mp(L,0);
else
A[te]=mp(L,A[te-1].se+1);
if(te==0)
p[0][te]=0;
else
p[0][te]=te-1;
for(ii=1;ii<LO[te+1];ii++)
p[ii][te]=p[ii-1][p[ii-1][te]];
te++;
}
void UndoCommands(int U)
{
A[te]=A[te-U-1];
p[0][te]=p[0][te-U-1];
for(ii=1;ii<LO[te+1];ii++)
p[ii][te]=p[ii-1][p[ii-1][te]];
te++;
// cek();
}
char GetLetter(int P)
{
X=te-1;
for(ii=LO[te+1]-1;ii>=0;ii--)
if(A[p[ii][X]].se>=P)
{
if(A[p[ii][X]].se==P)
{
X=p[ii][X];
break;
}
X=p[ii][X];
}
return char(A[X].fi);
// return hai[P];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
36 ms |
4344 KB |
Output is correct |
2 |
Correct |
32 ms |
4224 KB |
Output is correct |
3 |
Correct |
31 ms |
4216 KB |
Output is correct |
4 |
Correct |
30 ms |
4352 KB |
Output is correct |
5 |
Correct |
31 ms |
4344 KB |
Output is correct |
6 |
Correct |
31 ms |
4472 KB |
Output is correct |
7 |
Correct |
30 ms |
4224 KB |
Output is correct |
8 |
Correct |
30 ms |
4268 KB |
Output is correct |
9 |
Correct |
30 ms |
4344 KB |
Output is correct |
10 |
Correct |
30 ms |
4344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
4216 KB |
Output is correct |
2 |
Correct |
30 ms |
4352 KB |
Output is correct |
3 |
Correct |
30 ms |
4344 KB |
Output is correct |
4 |
Correct |
30 ms |
4292 KB |
Output is correct |
5 |
Correct |
30 ms |
4216 KB |
Output is correct |
6 |
Correct |
31 ms |
4216 KB |
Output is correct |
7 |
Correct |
95 ms |
4364 KB |
Output is correct |
8 |
Correct |
31 ms |
4216 KB |
Output is correct |
9 |
Correct |
32 ms |
4348 KB |
Output is correct |
10 |
Correct |
30 ms |
4216 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
31 ms |
4428 KB |
Output is correct |
2 |
Correct |
31 ms |
4472 KB |
Output is correct |
3 |
Correct |
32 ms |
4572 KB |
Output is correct |
4 |
Correct |
32 ms |
4572 KB |
Output is correct |
5 |
Correct |
31 ms |
4472 KB |
Output is correct |
6 |
Correct |
32 ms |
4600 KB |
Output is correct |
7 |
Correct |
32 ms |
4600 KB |
Output is correct |
8 |
Correct |
32 ms |
4608 KB |
Output is correct |
9 |
Correct |
32 ms |
4604 KB |
Output is correct |
10 |
Correct |
32 ms |
4600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
418 ms |
61948 KB |
Output is correct |
2 |
Correct |
494 ms |
75640 KB |
Output is correct |
3 |
Correct |
438 ms |
74996 KB |
Output is correct |
4 |
Correct |
490 ms |
78716 KB |
Output is correct |
5 |
Correct |
490 ms |
69484 KB |
Output is correct |
6 |
Correct |
359 ms |
81912 KB |
Output is correct |
7 |
Execution timed out |
1078 ms |
70144 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
696 ms |
56896 KB |
Output is correct |
2 |
Correct |
852 ms |
49528 KB |
Output is correct |
3 |
Correct |
478 ms |
67888 KB |
Output is correct |
4 |
Correct |
449 ms |
60920 KB |
Output is correct |
5 |
Correct |
385 ms |
77432 KB |
Output is correct |
6 |
Correct |
418 ms |
79736 KB |
Output is correct |
7 |
Correct |
432 ms |
79736 KB |
Output is correct |
8 |
Execution timed out |
1076 ms |
65784 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |