#include "choreography.h"
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define BIT(x, i) ((x) >> (i) & 1)
#define MASK(i) (1LL << (i))
#define left ___left
#define right ___right
#define ALL(v) (v).begin(), (v).end()
#define REP(i, n) for (int i = 0, _n = (n); i < _n; ++i)
#define REPD(i, n) for (int i = (n); i-- > 0; )
#define FOR(i, a, b) for (int _b = (b); i = (a); i < _b; ++i)
#define FORD(i, b, a) for (int _a = (a); i = (b); i-- > _a; )
#define FORE(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define FORDE(i, b, a) for (int i = (b), _a = (a); i >= _a; --i)
#define scan_op(...) istream & operator >> (istream &in, __VA_ARGS__ &u)
#define print_op(...) ostream & operator << (ostream &out, const __VA_ARGS__ &u)
#define file(name) if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
template <class U, class V> scan_op(pair <U, V>) { return in >> u.fi >> u.se; }
template <class T> scan_op(vector <T>) { for (T &x: u) in >> x; return in; }
template <class U, class V> print_op(pair <U, V>) { return out << "(" << u.fi << ", " << u.se << ")"; }
template <size_t i, class T> ostream & print_tuple_utils(ostream &out, const T &tup) { if constexpr(i == tuple_size<T>::value) return out << ")"; else return print_tuple_utils<i + 1, T>(out << (i ? ", " : "(") << get<i>(tup), tup); }
template <class ...U> print_op(tuple <U...>) { return print_tuple_utils<0, tuple <U...>> (out, u); }
template <class Con, class = decltype(begin(declval<Con>()))> typename enable_if <!is_same<Con, string>::value, ostream &>::type operator << (ostream &out, const Con &u) { out << "{"; for (auto it = u.begin(); it != u.end(); ++it) out << (it == u.begin() ? "" : ", ") << *it; return out << "}"; }
const int MAX = 1e5 + 5;
int N, A[2][MAX], add[2], rem[2], cur = 1;
void init(int n, vector <int> P) {
N = n;
REP(i, N) {
A[0][i] = P[i];
A[1][P[i]] = i;
}
}
void move_right(int K) {
REP(i, 2) {
add[i] += K;
if (add[i] >= N) add[i] -= N;
}
}
void move_left(int K) {
move_right(N - K);
}
void swap_places() {
REP(i, 2) add[i] += (add[i] & 1) == i ? 1 : -1;
}
void move_around() {
cur ^= 1;
REP(i, 2) swap(add[i], rem[i]);
}
int get_position(int D) {
D -= rem[(D - rem[0]) & 1];
if (D < 0) D += N;
D = A[cur][D];
D += add[D & 1];
if (D >= N) D -= N;
return D;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
71 ms |
9276 KB |
Output is correct |
2 |
Correct |
65 ms |
9132 KB |
Output is correct |
3 |
Correct |
65 ms |
9160 KB |
Output is correct |
4 |
Correct |
66 ms |
9160 KB |
Output is correct |
5 |
Correct |
53 ms |
6616 KB |
Output is correct |
6 |
Correct |
42 ms |
6604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 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 |
2 ms |
604 KB |
Output is correct |
6 |
Correct |
3 ms |
860 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
59 ms |
8528 KB |
Output is correct |
2 |
Correct |
58 ms |
8648 KB |
Output is correct |
3 |
Correct |
60 ms |
8656 KB |
Output is correct |
4 |
Correct |
35 ms |
6096 KB |
Output is correct |
5 |
Correct |
36 ms |
6100 KB |
Output is correct |
6 |
Correct |
60 ms |
6088 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
59 ms |
8528 KB |
Output is correct |
2 |
Correct |
58 ms |
8648 KB |
Output is correct |
3 |
Correct |
60 ms |
8656 KB |
Output is correct |
4 |
Correct |
35 ms |
6096 KB |
Output is correct |
5 |
Correct |
36 ms |
6100 KB |
Output is correct |
6 |
Correct |
60 ms |
6088 KB |
Output is correct |
7 |
Correct |
58 ms |
8648 KB |
Output is correct |
8 |
Correct |
63 ms |
8664 KB |
Output is correct |
9 |
Correct |
59 ms |
8524 KB |
Output is correct |
10 |
Correct |
43 ms |
6092 KB |
Output is correct |
11 |
Correct |
35 ms |
6092 KB |
Output is correct |
12 |
Correct |
35 ms |
6092 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
71 ms |
9276 KB |
Output is correct |
2 |
Correct |
65 ms |
9132 KB |
Output is correct |
3 |
Correct |
65 ms |
9160 KB |
Output is correct |
4 |
Correct |
66 ms |
9160 KB |
Output is correct |
5 |
Correct |
53 ms |
6616 KB |
Output is correct |
6 |
Correct |
42 ms |
6604 KB |
Output is correct |
7 |
Correct |
59 ms |
8528 KB |
Output is correct |
8 |
Correct |
58 ms |
8648 KB |
Output is correct |
9 |
Correct |
60 ms |
8656 KB |
Output is correct |
10 |
Correct |
35 ms |
6096 KB |
Output is correct |
11 |
Correct |
36 ms |
6100 KB |
Output is correct |
12 |
Correct |
60 ms |
6088 KB |
Output is correct |
13 |
Correct |
64 ms |
9044 KB |
Output is correct |
14 |
Correct |
64 ms |
8916 KB |
Output is correct |
15 |
Correct |
63 ms |
8904 KB |
Output is correct |
16 |
Correct |
41 ms |
6476 KB |
Output is correct |
17 |
Correct |
40 ms |
6360 KB |
Output is correct |
18 |
Correct |
41 ms |
6348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
71 ms |
9276 KB |
Output is correct |
2 |
Correct |
65 ms |
9132 KB |
Output is correct |
3 |
Correct |
65 ms |
9160 KB |
Output is correct |
4 |
Correct |
66 ms |
9160 KB |
Output is correct |
5 |
Correct |
53 ms |
6616 KB |
Output is correct |
6 |
Correct |
42 ms |
6604 KB |
Output is correct |
7 |
Correct |
1 ms |
348 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 |
2 ms |
604 KB |
Output is correct |
12 |
Correct |
3 ms |
860 KB |
Output is correct |
13 |
Correct |
59 ms |
8528 KB |
Output is correct |
14 |
Correct |
58 ms |
8648 KB |
Output is correct |
15 |
Correct |
60 ms |
8656 KB |
Output is correct |
16 |
Correct |
35 ms |
6096 KB |
Output is correct |
17 |
Correct |
36 ms |
6100 KB |
Output is correct |
18 |
Correct |
60 ms |
6088 KB |
Output is correct |
19 |
Correct |
58 ms |
8648 KB |
Output is correct |
20 |
Correct |
63 ms |
8664 KB |
Output is correct |
21 |
Correct |
59 ms |
8524 KB |
Output is correct |
22 |
Correct |
43 ms |
6092 KB |
Output is correct |
23 |
Correct |
35 ms |
6092 KB |
Output is correct |
24 |
Correct |
35 ms |
6092 KB |
Output is correct |
25 |
Correct |
64 ms |
9044 KB |
Output is correct |
26 |
Correct |
64 ms |
8916 KB |
Output is correct |
27 |
Correct |
63 ms |
8904 KB |
Output is correct |
28 |
Correct |
41 ms |
6476 KB |
Output is correct |
29 |
Correct |
40 ms |
6360 KB |
Output is correct |
30 |
Correct |
41 ms |
6348 KB |
Output is correct |
31 |
Correct |
64 ms |
8840 KB |
Output is correct |
32 |
Correct |
63 ms |
8804 KB |
Output is correct |
33 |
Correct |
65 ms |
8952 KB |
Output is correct |
34 |
Correct |
39 ms |
6468 KB |
Output is correct |
35 |
Correct |
39 ms |
6348 KB |
Output is correct |
36 |
Correct |
40 ms |
6348 KB |
Output is correct |