답안 #899608

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
899608 2024-01-06T14:38:40 Z marvinthang Choreography (IOI23_choreography) C++17
100 / 100
86 ms 9300 KB
#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], sum[2], flip[2], cur;

void init(int _N, vector <int> P) {
    N = _N;
    REP(i, N) {
        A[0][i] = P[i];
        A[1][P[i]] = i;
    }
} 

void add(int &a, int b) {
    a = (a + b) % N;
    if (a < 0) a += N;
}

void move_right(int K) {
    add(sum[cur], K);
    if (K & 1) flip[cur] = -flip[cur];
}

void move_left(int K) {
    add(sum[cur], -K);
    if (K & 1) flip[cur] = -flip[cur];
}

void swap_places() {
    flip[cur] = -flip[cur];
    add(flip[cur], 1);
}

void move_around() {
    cur ^= 1;
}

int get_position(int D) {
    if (D & 1) add(D, -flip[cur ^ 1]);
    else add(D, flip[cur ^ 1]);
    add(D, -sum[cur ^ 1]);
    int a = A[cur ^ 1][D];
    add(a, sum[cur]);
    add(a, flip[cur]);
    if (!(a & 1)) add(a, -2 * flip[cur]);
    return a;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 9156 KB Output is correct
2 Correct 68 ms 9300 KB Output is correct
3 Correct 69 ms 9088 KB Output is correct
4 Correct 68 ms 9116 KB Output is correct
5 Correct 44 ms 6600 KB Output is correct
6 Correct 44 ms 6600 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 1 ms 604 KB Output is correct
6 Correct 3 ms 860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 8524 KB Output is correct
2 Correct 60 ms 8644 KB Output is correct
3 Correct 61 ms 8648 KB Output is correct
4 Correct 36 ms 6216 KB Output is correct
5 Correct 36 ms 5968 KB Output is correct
6 Correct 36 ms 5992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 8524 KB Output is correct
2 Correct 60 ms 8644 KB Output is correct
3 Correct 61 ms 8648 KB Output is correct
4 Correct 36 ms 6216 KB Output is correct
5 Correct 36 ms 5968 KB Output is correct
6 Correct 36 ms 5992 KB Output is correct
7 Correct 62 ms 8648 KB Output is correct
8 Correct 65 ms 8676 KB Output is correct
9 Correct 61 ms 8664 KB Output is correct
10 Correct 36 ms 6088 KB Output is correct
11 Correct 37 ms 6092 KB Output is correct
12 Correct 36 ms 5924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 9156 KB Output is correct
2 Correct 68 ms 9300 KB Output is correct
3 Correct 69 ms 9088 KB Output is correct
4 Correct 68 ms 9116 KB Output is correct
5 Correct 44 ms 6600 KB Output is correct
6 Correct 44 ms 6600 KB Output is correct
7 Correct 61 ms 8524 KB Output is correct
8 Correct 60 ms 8644 KB Output is correct
9 Correct 61 ms 8648 KB Output is correct
10 Correct 36 ms 6216 KB Output is correct
11 Correct 36 ms 5968 KB Output is correct
12 Correct 36 ms 5992 KB Output is correct
13 Correct 86 ms 8908 KB Output is correct
14 Correct 66 ms 9008 KB Output is correct
15 Correct 66 ms 9044 KB Output is correct
16 Correct 45 ms 6632 KB Output is correct
17 Correct 43 ms 6348 KB Output is correct
18 Correct 43 ms 6344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 9156 KB Output is correct
2 Correct 68 ms 9300 KB Output is correct
3 Correct 69 ms 9088 KB Output is correct
4 Correct 68 ms 9116 KB Output is correct
5 Correct 44 ms 6600 KB Output is correct
6 Correct 44 ms 6600 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 1 ms 604 KB Output is correct
12 Correct 3 ms 860 KB Output is correct
13 Correct 61 ms 8524 KB Output is correct
14 Correct 60 ms 8644 KB Output is correct
15 Correct 61 ms 8648 KB Output is correct
16 Correct 36 ms 6216 KB Output is correct
17 Correct 36 ms 5968 KB Output is correct
18 Correct 36 ms 5992 KB Output is correct
19 Correct 62 ms 8648 KB Output is correct
20 Correct 65 ms 8676 KB Output is correct
21 Correct 61 ms 8664 KB Output is correct
22 Correct 36 ms 6088 KB Output is correct
23 Correct 37 ms 6092 KB Output is correct
24 Correct 36 ms 5924 KB Output is correct
25 Correct 86 ms 8908 KB Output is correct
26 Correct 66 ms 9008 KB Output is correct
27 Correct 66 ms 9044 KB Output is correct
28 Correct 45 ms 6632 KB Output is correct
29 Correct 43 ms 6348 KB Output is correct
30 Correct 43 ms 6344 KB Output is correct
31 Correct 66 ms 9024 KB Output is correct
32 Correct 73 ms 9200 KB Output is correct
33 Correct 65 ms 8900 KB Output is correct
34 Correct 41 ms 6344 KB Output is correct
35 Correct 40 ms 6328 KB Output is correct
36 Correct 41 ms 6344 KB Output is correct