char ops[1000005];
int prev[1000005][20], size[1000005], sz;
int go[1000005];
void Init(){
sz = 1;
}
void TypeLetter(char L){
int p = sz;
go[p] = p;
ops[p] = L;
if(p)prev[p][0]=go[p-1];
for(int i=1;prev[p][i-1];i++)
prev[p][i] = prev[prev[p][i-1]][i-1];
size[p]=size[go[p-1]]+1;
sz++;
}
void UndoCommands(int U){
go[sz]=go[sz-U-1];
sz++;
}
char GetLetter(int P){
int pos = go[sz-1];
int o = P+1;
for(int i=19;i>=0;i--)
if(size[prev[pos][i]]>=o)
pos = prev[pos][i];
return ops[pos];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
4 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 |
7 ms |
768 KB |
Output is correct |
4 |
Correct |
6 ms |
768 KB |
Output is correct |
5 |
Correct |
6 ms |
640 KB |
Output is correct |
6 |
Correct |
5 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 |
6 ms |
768 KB |
Output is correct |
10 |
Correct |
6 ms |
768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
382 ms |
66520 KB |
Output is correct |
2 |
Correct |
404 ms |
80504 KB |
Output is correct |
3 |
Correct |
337 ms |
80760 KB |
Output is correct |
4 |
Correct |
382 ms |
85880 KB |
Output is correct |
5 |
Correct |
478 ms |
75036 KB |
Output is correct |
6 |
Correct |
340 ms |
87060 KB |
Output is correct |
7 |
Correct |
511 ms |
76792 KB |
Output is correct |
8 |
Correct |
385 ms |
85244 KB |
Output is correct |
9 |
Correct |
425 ms |
81400 KB |
Output is correct |
10 |
Correct |
231 ms |
90616 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
580 ms |
62328 KB |
Output is correct |
2 |
Correct |
681 ms |
55032 KB |
Output is correct |
3 |
Correct |
375 ms |
68600 KB |
Output is correct |
4 |
Correct |
445 ms |
61560 KB |
Output is correct |
5 |
Correct |
444 ms |
78328 KB |
Output is correct |
6 |
Correct |
418 ms |
80760 KB |
Output is correct |
7 |
Correct |
451 ms |
80680 KB |
Output is correct |
8 |
Correct |
719 ms |
70060 KB |
Output is correct |
9 |
Correct |
751 ms |
67172 KB |
Output is correct |
10 |
Correct |
238 ms |
89312 KB |
Output is correct |