#include "choreography.h"
#include <vector>
using namespace std;
int x0 = 0, x1 = 0, i0 = 0, i1 = 0, n;
bool s = false;
vector<int> p, inv;
void init(int N, 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;
swap(x0, i0);
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 |
58 ms |
9160 KB |
Output is correct |
2 |
Correct |
59 ms |
9152 KB |
Output is correct |
3 |
Correct |
60 ms |
9156 KB |
Output is correct |
4 |
Correct |
70 ms |
9160 KB |
Output is correct |
5 |
Correct |
42 ms |
6680 KB |
Output is correct |
6 |
Correct |
37 ms |
6600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
3 ms |
860 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
2 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
8700 KB |
Output is correct |
2 |
Correct |
50 ms |
8644 KB |
Output is correct |
3 |
Correct |
53 ms |
8648 KB |
Output is correct |
4 |
Correct |
30 ms |
6344 KB |
Output is correct |
5 |
Correct |
30 ms |
6088 KB |
Output is correct |
6 |
Correct |
30 ms |
6092 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
8700 KB |
Output is correct |
2 |
Correct |
50 ms |
8644 KB |
Output is correct |
3 |
Correct |
53 ms |
8648 KB |
Output is correct |
4 |
Correct |
30 ms |
6344 KB |
Output is correct |
5 |
Correct |
30 ms |
6088 KB |
Output is correct |
6 |
Correct |
30 ms |
6092 KB |
Output is correct |
7 |
Correct |
53 ms |
8644 KB |
Output is correct |
8 |
Correct |
52 ms |
8644 KB |
Output is correct |
9 |
Correct |
62 ms |
8892 KB |
Output is correct |
10 |
Correct |
30 ms |
6088 KB |
Output is correct |
11 |
Correct |
33 ms |
6092 KB |
Output is correct |
12 |
Correct |
30 ms |
6092 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
9160 KB |
Output is correct |
2 |
Correct |
59 ms |
9152 KB |
Output is correct |
3 |
Correct |
60 ms |
9156 KB |
Output is correct |
4 |
Correct |
70 ms |
9160 KB |
Output is correct |
5 |
Correct |
42 ms |
6680 KB |
Output is correct |
6 |
Correct |
37 ms |
6600 KB |
Output is correct |
7 |
Correct |
54 ms |
8700 KB |
Output is correct |
8 |
Correct |
50 ms |
8644 KB |
Output is correct |
9 |
Correct |
53 ms |
8648 KB |
Output is correct |
10 |
Correct |
30 ms |
6344 KB |
Output is correct |
11 |
Correct |
30 ms |
6088 KB |
Output is correct |
12 |
Correct |
30 ms |
6092 KB |
Output is correct |
13 |
Correct |
62 ms |
8900 KB |
Output is correct |
14 |
Correct |
57 ms |
8896 KB |
Output is correct |
15 |
Correct |
57 ms |
9016 KB |
Output is correct |
16 |
Correct |
37 ms |
6428 KB |
Output is correct |
17 |
Correct |
37 ms |
6348 KB |
Output is correct |
18 |
Correct |
38 ms |
6344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
9160 KB |
Output is correct |
2 |
Correct |
59 ms |
9152 KB |
Output is correct |
3 |
Correct |
60 ms |
9156 KB |
Output is correct |
4 |
Correct |
70 ms |
9160 KB |
Output is correct |
5 |
Correct |
42 ms |
6680 KB |
Output is correct |
6 |
Correct |
37 ms |
6600 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
3 ms |
860 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
2 ms |
860 KB |
Output is correct |
13 |
Correct |
54 ms |
8700 KB |
Output is correct |
14 |
Correct |
50 ms |
8644 KB |
Output is correct |
15 |
Correct |
53 ms |
8648 KB |
Output is correct |
16 |
Correct |
30 ms |
6344 KB |
Output is correct |
17 |
Correct |
30 ms |
6088 KB |
Output is correct |
18 |
Correct |
30 ms |
6092 KB |
Output is correct |
19 |
Correct |
53 ms |
8644 KB |
Output is correct |
20 |
Correct |
52 ms |
8644 KB |
Output is correct |
21 |
Correct |
62 ms |
8892 KB |
Output is correct |
22 |
Correct |
30 ms |
6088 KB |
Output is correct |
23 |
Correct |
33 ms |
6092 KB |
Output is correct |
24 |
Correct |
30 ms |
6092 KB |
Output is correct |
25 |
Correct |
62 ms |
8900 KB |
Output is correct |
26 |
Correct |
57 ms |
8896 KB |
Output is correct |
27 |
Correct |
57 ms |
9016 KB |
Output is correct |
28 |
Correct |
37 ms |
6428 KB |
Output is correct |
29 |
Correct |
37 ms |
6348 KB |
Output is correct |
30 |
Correct |
38 ms |
6344 KB |
Output is correct |
31 |
Correct |
61 ms |
8900 KB |
Output is correct |
32 |
Correct |
57 ms |
9016 KB |
Output is correct |
33 |
Correct |
60 ms |
8884 KB |
Output is correct |
34 |
Correct |
35 ms |
6348 KB |
Output is correct |
35 |
Correct |
34 ms |
6352 KB |
Output is correct |
36 |
Correct |
35 ms |
6432 KB |
Output is correct |