#include <bits/stdc++.h>
using namespace std;
using pic = pair<int, char>;
const int N = 1e6+10;
const int LN = 20;
int cnt;
char chr[N];
int len[N];
int par[N][LN];
int ptr[N];
int link(int p, char c)
{
chr[++cnt] = c;
par[cnt][0] = p;
len[cnt] = len[p]+1;
for (int i = 1; i < LN; ++i)
par[cnt][i] = par[par[cnt][i-1]][i-1];
return cnt;
}
void Init() {
//printf("Init()\n");
}
int vc;
void TypeLetter(char L) {
//printf("TypeLetter(%c)\n", L);
++vc;
ptr[vc] = link(ptr[vc-1], L);
}
void UndoCommands(int U)
{
//printf("UndoCommands(%d)\n", U);
U = min(U, vc);
++vc;
ptr[vc] = ptr[vc-U-1];
}
char GetLetter(int P)
{
int u = ptr[vc];
P = len[ptr[vc]]-P-1;
for (int i = LN-1; i >= 0; --i)
if ((1<<i)&P) u = par[u][i];
//printf("GetLetter(%d) = %c\n", P, ans);
return chr[u];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
488 KB |
Output is correct |
3 |
Correct |
2 ms |
600 KB |
Output is correct |
4 |
Correct |
2 ms |
712 KB |
Output is correct |
5 |
Correct |
3 ms |
712 KB |
Output is correct |
6 |
Correct |
3 ms |
796 KB |
Output is correct |
7 |
Correct |
2 ms |
796 KB |
Output is correct |
8 |
Correct |
4 ms |
796 KB |
Output is correct |
9 |
Correct |
2 ms |
796 KB |
Output is correct |
10 |
Correct |
3 ms |
796 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
796 KB |
Output is correct |
2 |
Correct |
4 ms |
796 KB |
Output is correct |
3 |
Correct |
2 ms |
796 KB |
Output is correct |
4 |
Correct |
3 ms |
796 KB |
Output is correct |
5 |
Correct |
2 ms |
796 KB |
Output is correct |
6 |
Correct |
3 ms |
796 KB |
Output is correct |
7 |
Correct |
2 ms |
796 KB |
Output is correct |
8 |
Correct |
3 ms |
796 KB |
Output is correct |
9 |
Correct |
2 ms |
796 KB |
Output is correct |
10 |
Correct |
2 ms |
796 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
924 KB |
Output is correct |
2 |
Correct |
4 ms |
936 KB |
Output is correct |
3 |
Correct |
7 ms |
976 KB |
Output is correct |
4 |
Correct |
4 ms |
1180 KB |
Output is correct |
5 |
Correct |
4 ms |
1180 KB |
Output is correct |
6 |
Correct |
4 ms |
1216 KB |
Output is correct |
7 |
Correct |
5 ms |
1240 KB |
Output is correct |
8 |
Correct |
4 ms |
1264 KB |
Output is correct |
9 |
Correct |
4 ms |
1264 KB |
Output is correct |
10 |
Correct |
3 ms |
1264 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
684 ms |
55976 KB |
Output is correct |
2 |
Correct |
737 ms |
65380 KB |
Output is correct |
3 |
Correct |
461 ms |
68944 KB |
Output is correct |
4 |
Correct |
440 ms |
68944 KB |
Output is correct |
5 |
Correct |
604 ms |
72748 KB |
Output is correct |
6 |
Correct |
416 ms |
89960 KB |
Output is correct |
7 |
Correct |
550 ms |
89960 KB |
Output is correct |
8 |
Correct |
521 ms |
89960 KB |
Output is correct |
9 |
Correct |
758 ms |
106604 KB |
Output is correct |
10 |
Correct |
277 ms |
106604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
758 ms |
106604 KB |
Output is correct |
2 |
Correct |
881 ms |
106604 KB |
Output is correct |
3 |
Correct |
527 ms |
106604 KB |
Output is correct |
4 |
Correct |
540 ms |
106604 KB |
Output is correct |
5 |
Correct |
593 ms |
120844 KB |
Output is correct |
6 |
Correct |
511 ms |
122584 KB |
Output is correct |
7 |
Correct |
522 ms |
130012 KB |
Output is correct |
8 |
Correct |
839 ms |
130012 KB |
Output is correct |
9 |
Execution timed out |
1029 ms |
134184 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |