Submission #911320

#TimeUsernameProblemLanguageResultExecution timeMemory
911320marvinthangChoreography (IOI23_choreography)C++17
100 / 100
71 ms9276 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...