#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
#pragma GCC target ("avx2")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int LOG=20,MX=(int)(1e6+1);
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) {
d[idx+1]=d[idx-U];
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];
if(idx!=U){
vec[up[idx-U][0]].pb(idx+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];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
23808 KB |
Output is correct |
2 |
Correct |
16 ms |
23808 KB |
Output is correct |
3 |
Correct |
17 ms |
23808 KB |
Output is correct |
4 |
Correct |
18 ms |
23876 KB |
Output is correct |
5 |
Correct |
18 ms |
23808 KB |
Output is correct |
6 |
Correct |
18 ms |
23808 KB |
Output is correct |
7 |
Correct |
18 ms |
23808 KB |
Output is correct |
8 |
Correct |
16 ms |
23808 KB |
Output is correct |
9 |
Correct |
18 ms |
23808 KB |
Output is correct |
10 |
Correct |
15 ms |
23808 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
23808 KB |
Output is correct |
2 |
Correct |
18 ms |
23808 KB |
Output is correct |
3 |
Correct |
17 ms |
23808 KB |
Output is correct |
4 |
Correct |
18 ms |
23808 KB |
Output is correct |
5 |
Correct |
16 ms |
23808 KB |
Output is correct |
6 |
Correct |
17 ms |
23808 KB |
Output is correct |
7 |
Correct |
16 ms |
23808 KB |
Output is correct |
8 |
Correct |
16 ms |
23808 KB |
Output is correct |
9 |
Correct |
16 ms |
23808 KB |
Output is correct |
10 |
Correct |
16 ms |
23808 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
19 ms |
24056 KB |
Output is correct |
2 |
Correct |
18 ms |
24064 KB |
Output is correct |
3 |
Correct |
18 ms |
24192 KB |
Output is correct |
4 |
Correct |
18 ms |
24320 KB |
Output is correct |
5 |
Correct |
18 ms |
24192 KB |
Output is correct |
6 |
Correct |
18 ms |
24320 KB |
Output is correct |
7 |
Correct |
18 ms |
24320 KB |
Output is correct |
8 |
Correct |
20 ms |
24320 KB |
Output is correct |
9 |
Correct |
18 ms |
24320 KB |
Output is correct |
10 |
Correct |
17 ms |
24320 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
491 ms |
101468 KB |
Output is correct |
2 |
Correct |
593 ms |
116720 KB |
Output is correct |
3 |
Correct |
583 ms |
115764 KB |
Output is correct |
4 |
Correct |
727 ms |
115856 KB |
Output is correct |
5 |
Correct |
596 ms |
107512 KB |
Output is correct |
6 |
Correct |
437 ms |
124280 KB |
Output is correct |
7 |
Execution timed out |
1006 ms |
102264 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
572 ms |
93816 KB |
Output is correct |
2 |
Correct |
623 ms |
84456 KB |
Output is correct |
3 |
Correct |
571 ms |
99192 KB |
Output is correct |
4 |
Correct |
592 ms |
87176 KB |
Output is correct |
5 |
Correct |
461 ms |
110104 KB |
Output is correct |
6 |
Correct |
508 ms |
111480 KB |
Output is correct |
7 |
Correct |
495 ms |
112376 KB |
Output is correct |
8 |
Correct |
965 ms |
93176 KB |
Output is correct |
9 |
Correct |
853 ms |
97272 KB |
Output is correct |
10 |
Correct |
361 ms |
124024 KB |
Output is correct |