#include <bits/stdc++.h>
#define MAX_N 1000000
#define MAX_P2 19
using namespace std;
int k;
int ant[MAX_N + 1][MAX_P2 + 1];
int stk[MAX_N + 1];
int d[MAX_N + 1];
char chr[MAX_N + 1];
void Init()
{
}
void TypeLetter(char L)
{
k ++;
ant[k][0] = stk[k - 1];
stk[k] = k;
chr[k] = L;
d[k] = d[ant[k][0]] + 1;
for(int p2 = 1; p2 <= 19; p2 ++)
ant[k][p2] = ant[ant[k][p2 - 1]][p2 - 1];
}
void UndoCommands(int U)
{
k ++;
stk[k] = stk[k - 1 - U];
}
char GetLetter(int P)
{
P ++;
int len = d[stk[k]] - P;
int cr = stk[k];
for(int i = 0; i <= 19; i ++)
{
if(((1 << i) & len) != 0)
cr = ant[cr][i];
}
return chr[cr];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
512 KB |
Output is correct |
2 |
Correct |
6 ms |
640 KB |
Output is correct |
3 |
Correct |
6 ms |
640 KB |
Output is correct |
4 |
Correct |
6 ms |
768 KB |
Output is correct |
5 |
Correct |
6 ms |
640 KB |
Output is correct |
6 |
Correct |
6 ms |
768 KB |
Output is correct |
7 |
Correct |
6 ms |
768 KB |
Output is correct |
8 |
Correct |
6 ms |
768 KB |
Output is correct |
9 |
Correct |
7 ms |
768 KB |
Output is correct |
10 |
Correct |
6 ms |
768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
372 ms |
66432 KB |
Output is correct |
2 |
Correct |
454 ms |
80504 KB |
Output is correct |
3 |
Correct |
446 ms |
80764 KB |
Output is correct |
4 |
Correct |
437 ms |
85856 KB |
Output is correct |
5 |
Correct |
454 ms |
75256 KB |
Output is correct |
6 |
Correct |
349 ms |
87092 KB |
Output is correct |
7 |
Correct |
486 ms |
76920 KB |
Output is correct |
8 |
Correct |
390 ms |
85244 KB |
Output is correct |
9 |
Correct |
429 ms |
81376 KB |
Output is correct |
10 |
Correct |
286 ms |
90616 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
455 ms |
62072 KB |
Output is correct |
2 |
Correct |
490 ms |
55024 KB |
Output is correct |
3 |
Correct |
377 ms |
68728 KB |
Output is correct |
4 |
Correct |
392 ms |
61432 KB |
Output is correct |
5 |
Correct |
362 ms |
78200 KB |
Output is correct |
6 |
Correct |
419 ms |
80632 KB |
Output is correct |
7 |
Correct |
381 ms |
80504 KB |
Output is correct |
8 |
Correct |
605 ms |
69752 KB |
Output is correct |
9 |
Correct |
507 ms |
66936 KB |
Output is correct |
10 |
Correct |
285 ms |
89372 KB |
Output is correct |