#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int LOG=20,MX=(int)(1e6+7);
int up[MX][LOG],d[MX],idx;
char car[MX];
vector<int> vec[MX];
void Init() {
}
void TypeLetter(char L) {
vec[idx].pb(idx+1);
d[idx+1]=d[idx]+1;
up[idx+1][0]=idx;
for (int i = 1; i < LOG; ++i)
up[idx+1][i]=up[up[idx+1][i-1]][i-1];
car[idx+1]=L;
idx++;
}
void UndoCommands(int U) {
vec[up[idx-U][0]].pb(idx+1);
d[idx+1]=d[up[idx-U][0]]+1;
up[idx+1][0]=up[idx-U][0];
for (int i = 1; i < LOG; ++i)
up[idx+1][i]=up[up[idx+1][i-1]][i-1];
car[idx+1]=car[idx-U];
idx++;
}
char GetLetter(int P) {
int k=d[idx]-1-P,a=idx;
for (int i = 0; i < LOG; ++i)
if((k>>i)&1)a=up[a][i];
return car[a];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
23808 KB |
Output is correct |
2 |
Correct |
17 ms |
23808 KB |
Output is correct |
3 |
Correct |
17 ms |
23808 KB |
Output is correct |
4 |
Correct |
17 ms |
23808 KB |
Output is correct |
5 |
Correct |
17 ms |
23808 KB |
Output is correct |
6 |
Correct |
17 ms |
23808 KB |
Output is correct |
7 |
Correct |
17 ms |
23808 KB |
Output is correct |
8 |
Correct |
17 ms |
23808 KB |
Output is correct |
9 |
Correct |
18 ms |
23808 KB |
Output is correct |
10 |
Correct |
17 ms |
23808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
23936 KB |
Output is correct |
2 |
Correct |
17 ms |
23808 KB |
Output is correct |
3 |
Correct |
18 ms |
23808 KB |
Output is correct |
4 |
Correct |
17 ms |
23808 KB |
Output is correct |
5 |
Correct |
18 ms |
23808 KB |
Output is correct |
6 |
Correct |
17 ms |
23808 KB |
Output is correct |
7 |
Correct |
17 ms |
23808 KB |
Output is correct |
8 |
Correct |
19 ms |
23808 KB |
Output is correct |
9 |
Correct |
17 ms |
23808 KB |
Output is correct |
10 |
Correct |
17 ms |
23808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
24064 KB |
Output is correct |
2 |
Correct |
20 ms |
24192 KB |
Output is correct |
3 |
Correct |
19 ms |
24320 KB |
Output is correct |
4 |
Correct |
19 ms |
24448 KB |
Output is correct |
5 |
Correct |
19 ms |
24192 KB |
Output is correct |
6 |
Correct |
19 ms |
24320 KB |
Output is correct |
7 |
Correct |
19 ms |
24320 KB |
Output is correct |
8 |
Correct |
19 ms |
24320 KB |
Output is correct |
9 |
Correct |
19 ms |
24320 KB |
Output is correct |
10 |
Correct |
19 ms |
24320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
474 ms |
103032 KB |
Output is correct |
2 |
Correct |
601 ms |
118264 KB |
Output is correct |
3 |
Correct |
585 ms |
117368 KB |
Output is correct |
4 |
Correct |
701 ms |
117112 KB |
Output is correct |
5 |
Correct |
527 ms |
108408 KB |
Output is correct |
6 |
Correct |
453 ms |
125432 KB |
Output is correct |
7 |
Execution timed out |
1044 ms |
103372 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
592 ms |
95224 KB |
Output is correct |
2 |
Correct |
604 ms |
85496 KB |
Output is correct |
3 |
Correct |
568 ms |
100088 KB |
Output is correct |
4 |
Correct |
596 ms |
88228 KB |
Output is correct |
5 |
Correct |
469 ms |
111096 KB |
Output is correct |
6 |
Correct |
506 ms |
112376 KB |
Output is correct |
7 |
Correct |
482 ms |
113400 KB |
Output is correct |
8 |
Execution timed out |
1056 ms |
93944 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |