// model_solution/solution.cpp
#include "choreography.h"
#include <vector>
int x0 = 0, x1 = 0, i0 = 0, i1 = 0, n;
bool s = false;
std::vector<int> p, inv;
void init(int N, std::vector<int> P){
n = N;
p = P;
inv.resize(N);
for(int i = 0; i < N; i++){
inv[P[i]] = i;
}
}
void move_right(int K){
x0 += + K;
x1 += + K;
if(x0 >= n) x0 -= n;
if(x1 >= n) x1 -= n;
}
void move_left(int K){
move_right(n - K);
}
void swap_places(){
x0 += x0&1 ? -1 : 1;
x1 += x1&1 ? 1 : -1;
if(x1 < 0) x1 += n;
if(x1 >= n) x1 -= n;
}
void move_around(){
s = !s;
std::swap(x0, i0);
std::swap(x1, i1);
}
int get_position(int D){
int i = (D-i0)%2 == 0 ? D - i0 : D - i1;
if(i < 0) i += n;
int x = s ? p[i] : inv[i];
int ans = x&1 ? x + x1 : x + x0;
return ans < n ? ans : ans - n;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
81 ms |
6164 KB |
Output is correct |
2 |
Correct |
101 ms |
6208 KB |
Output is correct |
3 |
Correct |
91 ms |
6228 KB |
Output is correct |
4 |
Correct |
72 ms |
6260 KB |
Output is correct |
5 |
Correct |
44 ms |
4420 KB |
Output is correct |
6 |
Correct |
42 ms |
4472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
4 ms |
724 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
3 ms |
752 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
6248 KB |
Output is correct |
2 |
Correct |
59 ms |
6216 KB |
Output is correct |
3 |
Correct |
63 ms |
6172 KB |
Output is correct |
4 |
Correct |
35 ms |
4420 KB |
Output is correct |
5 |
Correct |
34 ms |
4420 KB |
Output is correct |
6 |
Correct |
38 ms |
4492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
6248 KB |
Output is correct |
2 |
Correct |
59 ms |
6216 KB |
Output is correct |
3 |
Correct |
63 ms |
6172 KB |
Output is correct |
4 |
Correct |
35 ms |
4420 KB |
Output is correct |
5 |
Correct |
34 ms |
4420 KB |
Output is correct |
6 |
Correct |
38 ms |
4492 KB |
Output is correct |
7 |
Correct |
58 ms |
6296 KB |
Output is correct |
8 |
Correct |
66 ms |
6212 KB |
Output is correct |
9 |
Correct |
64 ms |
6220 KB |
Output is correct |
10 |
Correct |
39 ms |
4460 KB |
Output is correct |
11 |
Correct |
53 ms |
4356 KB |
Output is correct |
12 |
Correct |
54 ms |
4480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
81 ms |
6164 KB |
Output is correct |
2 |
Correct |
101 ms |
6208 KB |
Output is correct |
3 |
Correct |
91 ms |
6228 KB |
Output is correct |
4 |
Correct |
72 ms |
6260 KB |
Output is correct |
5 |
Correct |
44 ms |
4420 KB |
Output is correct |
6 |
Correct |
42 ms |
4472 KB |
Output is correct |
7 |
Correct |
58 ms |
6248 KB |
Output is correct |
8 |
Correct |
59 ms |
6216 KB |
Output is correct |
9 |
Correct |
63 ms |
6172 KB |
Output is correct |
10 |
Correct |
35 ms |
4420 KB |
Output is correct |
11 |
Correct |
34 ms |
4420 KB |
Output is correct |
12 |
Correct |
38 ms |
4492 KB |
Output is correct |
13 |
Correct |
65 ms |
6220 KB |
Output is correct |
14 |
Correct |
66 ms |
6216 KB |
Output is correct |
15 |
Correct |
81 ms |
6192 KB |
Output is correct |
16 |
Correct |
53 ms |
4416 KB |
Output is correct |
17 |
Correct |
45 ms |
4420 KB |
Output is correct |
18 |
Correct |
45 ms |
4420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
81 ms |
6164 KB |
Output is correct |
2 |
Correct |
101 ms |
6208 KB |
Output is correct |
3 |
Correct |
91 ms |
6228 KB |
Output is correct |
4 |
Correct |
72 ms |
6260 KB |
Output is correct |
5 |
Correct |
44 ms |
4420 KB |
Output is correct |
6 |
Correct |
42 ms |
4472 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
256 KB |
Output is correct |
10 |
Correct |
4 ms |
724 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
3 ms |
752 KB |
Output is correct |
13 |
Correct |
58 ms |
6248 KB |
Output is correct |
14 |
Correct |
59 ms |
6216 KB |
Output is correct |
15 |
Correct |
63 ms |
6172 KB |
Output is correct |
16 |
Correct |
35 ms |
4420 KB |
Output is correct |
17 |
Correct |
34 ms |
4420 KB |
Output is correct |
18 |
Correct |
38 ms |
4492 KB |
Output is correct |
19 |
Correct |
58 ms |
6296 KB |
Output is correct |
20 |
Correct |
66 ms |
6212 KB |
Output is correct |
21 |
Correct |
64 ms |
6220 KB |
Output is correct |
22 |
Correct |
39 ms |
4460 KB |
Output is correct |
23 |
Correct |
53 ms |
4356 KB |
Output is correct |
24 |
Correct |
54 ms |
4480 KB |
Output is correct |
25 |
Correct |
65 ms |
6220 KB |
Output is correct |
26 |
Correct |
66 ms |
6216 KB |
Output is correct |
27 |
Correct |
81 ms |
6192 KB |
Output is correct |
28 |
Correct |
53 ms |
4416 KB |
Output is correct |
29 |
Correct |
45 ms |
4420 KB |
Output is correct |
30 |
Correct |
45 ms |
4420 KB |
Output is correct |
31 |
Correct |
63 ms |
6204 KB |
Output is correct |
32 |
Correct |
67 ms |
6184 KB |
Output is correct |
33 |
Correct |
79 ms |
6196 KB |
Output is correct |
34 |
Correct |
51 ms |
4392 KB |
Output is correct |
35 |
Correct |
40 ms |
4420 KB |
Output is correct |
36 |
Correct |
40 ms |
4548 KB |
Output is correct |