結果

問題 No.2732 Similar Permutations
ユーザー miscalcmiscalc
提出日時 2024-04-19 22:27:04
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 11,356 bytes
コンパイル時間 6,556 ms
コンパイル使用メモリ 336,724 KB
実行使用メモリ 37,760 KB
最終ジャッジ日時 2024-04-19 22:27:30
合計ジャッジ時間 24,248 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
27,136 KB
testcase_01 AC 20 ms
26,752 KB
testcase_02 AC 46 ms
28,416 KB
testcase_03 AC 71 ms
30,720 KB
testcase_04 AC 33 ms
27,776 KB
testcase_05 AC 29 ms
27,776 KB
testcase_06 AC 22 ms
27,392 KB
testcase_07 AC 59 ms
31,104 KB
testcase_08 AC 37 ms
28,672 KB
testcase_09 AC 27 ms
28,032 KB
testcase_10 AC 117 ms
37,760 KB
testcase_11 AC 23 ms
27,264 KB
testcase_12 AC 112 ms
31,616 KB
testcase_13 AC 112 ms
31,616 KB
testcase_14 AC 113 ms
31,744 KB
testcase_15 AC 112 ms
31,616 KB
testcase_16 AC 84 ms
31,488 KB
testcase_17 AC 83 ms
31,616 KB
testcase_18 AC 106 ms
32,640 KB
testcase_19 AC 114 ms
31,616 KB
testcase_20 AC 115 ms
33,024 KB
testcase_21 AC 113 ms
31,744 KB
testcase_22 AC 74 ms
29,696 KB
testcase_23 AC 110 ms
33,152 KB
testcase_24 AC 72 ms
29,696 KB
testcase_25 AC 116 ms
33,152 KB
testcase_26 AC 97 ms
31,104 KB
testcase_27 AC 115 ms
33,152 KB
testcase_28 AC 105 ms
30,848 KB
testcase_29 AC 112 ms
33,408 KB
testcase_30 AC 86 ms
30,464 KB
testcase_31 AC 109 ms
31,744 KB
testcase_32 AC 111 ms
31,488 KB
testcase_33 AC 107 ms
31,744 KB
testcase_34 AC 85 ms
30,080 KB
testcase_35 AC 115 ms
31,744 KB
testcase_36 AC 108 ms
31,360 KB
testcase_37 AC 124 ms
31,744 KB
testcase_38 AC 98 ms
31,104 KB
testcase_39 AC 109 ms
31,872 KB
testcase_40 AC 96 ms
30,976 KB
testcase_41 AC 111 ms
31,872 KB
testcase_42 AC 89 ms
30,720 KB
testcase_43 AC 111 ms
31,744 KB
testcase_44 AC 65 ms
29,440 KB
testcase_45 AC 112 ms
31,872 KB
testcase_46 AC 102 ms
31,488 KB
testcase_47 AC 113 ms
31,872 KB
testcase_48 AC 73 ms
29,824 KB
testcase_49 AC 103 ms
31,744 KB
testcase_50 AC 70 ms
29,824 KB
testcase_51 AC 100 ms
31,872 KB
testcase_52 AC 85 ms
31,104 KB
testcase_53 AC 115 ms
34,816 KB
testcase_54 AC 114 ms
33,408 KB
testcase_55 AC 110 ms
31,744 KB
testcase_56 AC 111 ms
31,744 KB
testcase_57 AC 70 ms
31,744 KB
testcase_58 AC 85 ms
33,536 KB
testcase_59 AC 81 ms
32,384 KB
testcase_60 AC 72 ms
31,360 KB
testcase_61 AC 66 ms
29,312 KB
testcase_62 AC 99 ms
33,408 KB
testcase_63 AC 20 ms
26,752 KB
testcase_64 AC 20 ms
26,752 KB
testcase_65 AC 20 ms
26,752 KB
testcase_66 AC 20 ms
26,624 KB
testcase_67 AC 19 ms
26,752 KB
testcase_68 AC 19 ms
26,624 KB
testcase_69 AC 17 ms
27,008 KB
testcase_70 AC 16 ms
26,880 KB
testcase_71 AC 16 ms
27,008 KB
testcase_72 AC 16 ms
26,880 KB
testcase_73 AC 16 ms
27,008 KB
testcase_74 AC 16 ms
27,136 KB
testcase_75 AC 17 ms
27,008 KB
testcase_76 AC 16 ms
27,008 KB
testcase_77 AC 16 ms
27,008 KB
testcase_78 AC 16 ms
26,880 KB
testcase_79 AC 16 ms
27,136 KB
testcase_80 AC 17 ms
27,008 KB
testcase_81 AC 16 ms
26,880 KB
testcase_82 AC 16 ms
26,880 KB
testcase_83 AC 17 ms
27,008 KB
testcase_84 AC 16 ms
27,008 KB
testcase_85 AC 16 ms
27,136 KB
testcase_86 AC 16 ms
27,008 KB
testcase_87 AC 16 ms
27,008 KB
testcase_88 AC 16 ms
26,880 KB
testcase_89 AC 17 ms
27,008 KB
testcase_90 AC 17 ms
26,880 KB
testcase_91 AC 17 ms
27,008 KB
testcase_92 AC 17 ms
27,264 KB
testcase_93 AC 16 ms
27,008 KB
testcase_94 AC 17 ms
27,136 KB
testcase_95 AC 17 ms
27,008 KB
testcase_96 AC 17 ms
26,880 KB
testcase_97 AC 16 ms
27,136 KB
testcase_98 AC 17 ms
27,008 KB
testcase_99 AC 16 ms
27,008 KB
testcase_100 AC 17 ms
27,008 KB
testcase_101 AC 16 ms
27,264 KB
testcase_102 AC 16 ms
27,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
using tlll = tuple<ll, ll, ll>;
using tllll = tuple<ll, ll, ll, ll>;
using vll = vector<ll>;
using vpll = vector<pll>;
using vtlll = vector<tlll>;
using vtllll = vector<tllll>;
using vstr = vector<string>;
using vvl = vector<vector<ll>>;
constexpr ll INF = 4'000'000'000'000'000'037;
template <class T, class U> bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }
template <class T, class U> bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
ll safemod(ll a, ll m) { ll res = a % m; if (res < 0) res += m; return res; }
ll divfloor(ll a, ll b) { if (b < 0) a = -a, b = -b; return (a - safemod(a, b)) / b; }
ll divceil(ll a, ll b) { if (b < 0) a = -a, b = -b; return divfloor(a + b - 1, b); }
ll pow_ll(ll a, ll b) { if (a == 0 || a == 1) return a; if (a == -1) return b & 1 ? -1 : 1; ll res = 1; for (int i = 0; i < b; i++) res *= a; return res; }
ll mul_limited(ll a, ll b, ll m = INF) { return b == 0 ? 0 : a > m / b ? m : a * b; }
ll pow_limited(ll a, ll b, ll m = INF) { if (a == 0 || a == 1) return a; ll res = 1; for (int i = 0; i < b; i++) { if (res > m / a) return m; res *= a; } return res; }
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(i, n) for (ll i = 0; i < ll(n); i++)
#define rep2(i, l, r) for (ll i = ll(l); i < ll(r); i++)
#define rep3(i, l, r, d) for (ll i = ll(l); (d) > 0 ? i < ll(r) : i > ll(r); i += d)
#define rep(...) overload4(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__)
#define all(a) (a).begin(), (a).end()
template <class T, class F = decltype(plus<>())> vector<T> cuml(vector<T> v, const F &op = plus<>(), const T &e = 0) { v.emplace_back(e); exclusive_scan(v.begin(), v.end(), v.begin(), e, op); return v; }
template <class T, class F = decltype(plus<>())> vector<T> cumr(vector<T> v, const F &op = plus<>(), const T &e = 0) { v.insert(v.begin(), e); exclusive_scan(v.rbegin(), v.rend(), v.rbegin(), e, op); return v; }
template <class T> vector<T> adjd(vector<T> v) { adjacent_difference(v.begin(), v.end(), v.begin()); return v; }
template <class T = ll> struct max_op { T operator()(const T &a, const T &b) const { return max(a, b); } };
template <class T = ll> struct min_op { T operator()(const T &a, const T &b) const { return min(a, b); } };
struct max_e { ll operator()() const { return -INF; } };
struct min_e { ll operator()() const { return INF; } };
template <class T> vector<T> cumlmax(const vector<T> &v) { return cuml(v, max_op<T>(), max_e()()); }
template <class T> vector<T> cumrmax(const vector<T> &v) { return cumr(v, max_op<T>(), max_e()()); }
template <class T> vector<T> cumlmin(const vector<T> &v) { return cuml(v, min_op<T>(), min_e()()); }
template <class T> vector<T> cumrmin(const vector<T> &v) { return cumr(v, min_op<T>(), min_e()()); }
template <class T> vector<T> sorted(vector<T> v) { sort(v.begin(), v.end()); return v; }
template <class T> vector<T> reversed(const vector<T> &v) { return {v.rbegin(), v.rend()}; }
template <class T> void unique(vector<T> &v) { v.erase(unique(v.begin(), v.end()), v.end()); }
template <class T> void sortunique(vector<T> &v) { sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); }
template <class T> void rotate(vector<T> v, int k) { rotate(v.begin(), v.begin() + k, v.end()); }
template <class T> vector<T> rotated(vector<T> v, int k) { rotate(v.begin(), v.begin() + k, v.end()); return v; }
string sorted(string s) { sort(s.begin(), s.end()); return s; }
string reversed(const string &s) { return {s.rbegin(), s.rend()}; }
void unique(string &s) { s.erase(unique(s.begin(), s.end()), s.end()); }
void sortunique(string &s) { sort(s.begin(), s.end()); s.erase(unique(s.begin(), s.end()), s.end()); }
void rotate(string &s, int k) { rotate(s.begin(), s.begin() + k, s.end()); }
string rotated(string s, int k) { rotate(s.begin(), s.begin() + k, s.end()); return s; }
template <class T> vector<vector<T>> transposed(const vector<vector<T>> &a) { const size_t n = a.size(), m = a.at(0).size(); vector<vector<T>> b(m, vector<T>(n)); for (size_t i = 0; i < n; i++) for (size_t j = 0; j < m; j++) b[j][i] = a[i].at(j); return b; }
template <class T, const size_t m> array<vector<T>, m> transposed(const vector<array<T, m>> &a) { const size_t n = a.size(); array<vector<T>, m> b; b.fill(vector<T>(n)); for (size_t i = 0; i < n; i++) for (size_t j = 0; j < m; j++) b[j][i] = a[i][j]; return b; }
template <class T, const size_t n> vector<array<T, n>> transposed(const array<vector<T>, n> &a) { const size_t m = a.at(0).size(); vector<array<T, n>> b(m); for (size_t i = 0; i < n; i++) for (size_t j = 0; j < m; j++) b[j][i] = a[i].at(j); return b; }
template <class T, class U> pair<vector<T>, vector<U>> transposed(const vector<pair<T, U>> &a) { const size_t n = a.size(); vector<T> b(n); vector<U> c(n); for (size_t i = 0; i < n; i++) b[i] = a[i].first, c[i] = a[i].second; return make_pair(b, c); }
template <class T, class U> vector<pair<T, U>> transposed(const pair<vector<T>, vector<U>> &a) { const size_t n = a.first.size(); vector<pair<T, U>> b(n); for (size_t i = 0; i < n; i++) b[i] = make_pair(a.first[i], a.second.at(i)); return b; }
template <class T1, class T2, class T3> tuple<vector<T1>, vector<T2>, vector<T3>> transposed(const vector<tuple<T1, T2, T3>> &a) { const size_t n = a.size(); vector<T1> b(n); vector<T2> c(n); vector<T3> d(n); for (size_t i = 0; i < n; i++) b[i] = get<0>(a[i]), c[i] = get<1>(a[i]), d[i] = get<2>(a[i]); return make_tuple(b, c, d); }
template <class T1, class T2, class T3> vector<tuple<T1, T2, T3>> transposed(const tuple<vector<T1>, vector<T2>, vector<T3>> &a) { const size_t n = get<0>(a).size(); vector<tuple<T1, T2, T3>> b(n); for (size_t i = 0; i < n; i++) b[i] = make_tuple(get<0>(a)[i], get<1>(a).at(i), get<2>(a).at(i)); return b; }
template <class T1, class T2, class T3, class T4> tuple<vector<T1>, vector<T2>, vector<T3>, vector<T4>> transposed(const vector<tuple<T1, T2, T3, T4>> &a) { const size_t n = a.size(); vector<T1> b(n); vector<T2> c(n); vector<T3> d(n); vector<T4> e(n); for (size_t i = 0; i < n; i++) b[i] = get<0>(a[i]), c[i] = get<1>(a[i]), d[i] = get<2>(a[i]), e[i] = get<3>(a[i]); return make_tuple(b, c, d, e); }
template <class T1, class T2, class T3, class T4> vector<tuple<T1, T2, T3, T4>> transposed(const tuple<vector<T1>, vector<T2>, vector<T3>, vector<T4>> &a) { const size_t n = get<0>(a).size(); vector<tuple<T1, T2, T3, T4>> b(n); for (size_t i = 0; i < n; i++) b[i] = make_tuple(get<0>(a)[i], get<1>(a).at(i), get<2>(a).at(i), get<3>(a).at(i)); return b; }
template <class T = ll> vector<T> digitvec(const string &s) { int n = s.size(); vector<T> a(n); for (int i = 0; i < n; i++) a[i] = s[i] - '0'; return a; }
#if __cplusplus < 202002L
ull bit_ceil(ull x) { ull y = 1; while (y < x) y <<= 1; return y; }
ull bit_floor(ull x) { ull y = 1; while (y <= x) y <<= 1; return y >> 1; }
ull bit_width(ull x) { ull y = 1, z = 0; while (y <= x) y <<= 1, z++; return z; }
ull countr_zero(ull x) { return __builtin_ctzll(x); }
ull popcount(ull x) { return __builtin_popcountll(x); }
ull has_single_bit(ull x) { return popcount(x) == 1; }
#endif
ull lsb_index(ull x) { assert(x != 0); return countr_zero(x); }
ull msb_index(ull x) { assert(x != 0); return bit_width(x) - 1; }
ull lsb_mask(ull x) { assert(x != 0); return x & -x; }
ull msb_mask(ull x) { assert(x != 0); return bit_floor(x); }
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
template <class T, internal::is_modint_t<T> * = nullptr> istream &operator>>(istream &is, T &a) { ll v; is >> v; a = v; return is; }
template <class T, internal::is_modint_t<T> * = nullptr> ostream &operator<<(ostream &os, const T &a) { os << a.val(); return os; }
#endif
template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template <class T1, class T2, class T3> istream &operator>>(istream &is, tuple<T1, T2, T3> &t) { is >> get<0>(t) >> get<1>(t) >> get<2>(t); return is; }
template <class T1, class T2, class T3, class T4> istream &operator>>(istream &is, tuple<T1, T2, T3, T4> &t) { is >> get<0>(t) >> get<1>(t) >> get<2>(t) >> get<3>(t); return is; }
template <class T, const size_t N> istream &operator>>(istream &is, array<T, N> &a) { for (size_t i = 0; i < N; i++) is >> a[i]; return is; } 
template <class... T> void input(T&... a) { (cin >> ... >> a); }
template <class T> void inputvec(int n, vector<T> &v) { v.resize(n); for (int i = 0; i < n; i++) cin >> v[i]; }
template <class T, class... Ts> void inputvec(int n, vector<T>& v, vector<Ts>&... vs) { inputvec(n, v); inputvec(n, vs...); }
template <class T> void inputvec2(int n, int m, vector<vector<T>> &v) { v.assign(n, vector<T>(m)); for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> v[i][j]; }
template <class T, class... Ts> void inputvec2(int n, int m, vector<T>& v, vector<Ts>&... vs) { inputvec2(n, m, v); inputvec2(n, m, vs...); }
template <class T, class... Ts> void print(const T& a, const Ts&... b) { cout << a; (cout << ... << (cout << ' ', b)); cout << '\n'; }
#define INT(...) int __VA_ARGS__; input(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__; input(__VA_ARGS__)
#define STR(...) string __VA_ARGS__; input(__VA_ARGS__)
#define VINT(n, ...) vector<int> __VA_ARGS__; inputvec(n, __VA_ARGS__)
#define VLL(n, ...) vector<ll> __VA_ARGS__; inputvec(n, __VA_ARGS__)
#define VSTR(n, ...) vector<string> __VA_ARGS__; inputvec(n, __VA_ARGS__)
#define VPLL(n, ...) vector<pll> __VA_ARGS__; inputvec(n, __VA_ARGS__)
#define VTLLL(n, ...) vector<tlll> __VA_ARGS__; inputvec(n, __VA_ARGS__)
#define VTLLLL(n, ...) vector<tllll> __VA_ARGS__; inputvec(n, __VA_ARGS__)
#define AL(n, ...) array<ll, n> __VA_ARGS__; input(__VA_ARGS__)
#define VAL(n, m, ...) vector<array<ll, m>> __VA_ARGS__; inputvec(n, __VA_ARGS__)
#define VVL(n, m, ...) vector<vector<ll>> __VA_ARGS__; inputvec2(n, m, __VA_ARGS__)
#define FINALANS(x) do { cout << (x) << '\n'; exit(0); } while (false)
template <class T> void printvec(const vector<T> &v) { int n = v.size(); for (int i = 0; i < n; i++) cout << v[i] << (i == n - 1 ? "" : " "); cout << '\n'; }
template <class T> void printvect(const vector<T> &v) { for (auto &vi : v) cout << vi << '\n';}
template <class T> void printvec2(const vector<vector<T>> &v) { for (auto &vi : v) printvec(vi); }
#if __has_include(<atcoder/all>)
using mint = modint998244353;
//using mint = modint1000000007;
//using mint = modint;
#define MINT(...) mint __VA_ARGS__; input(__VA_ARGS__);
#define VMINT(n, ...) vector<mint> __VA_ARGS__; inputvec(n, __VA_ARGS__)
#endif
#ifdef LOCAL // https://zenn.dev/sassan/articles/19db660e4da0a4
#include "/Users/Shared/cpp-dump-main/dump.hpp"
#define dump(...) cpp_dump(__VA_ARGS__)
CPP_DUMP_DEFINE_EXPORT_OBJECT(mint, val());
CPP_DUMP_DEFINE_DANGEROUS_EXPORT_OBJECT(val());
#else
#define dump(...)
#endif

int main()
{
  LL(N);
  VLL(N, A);
  const ll M = 1000000;
  vvl P(M);
  vll Q(N);
  rep(i, N) Q.at(i) = i + 1;
  do
  {
    ll x = 0;
    rep(i, N)
    {
      x ^= (A.at(i) + Q.at(i));
    }
    if (P.at(x).empty())
      P.at(x) = Q;
    else
    {
      printvec(P.at(x)), printvec(Q);
      exit(0);
    }
  } while (next_permutation(all(Q)));
  cout << -1 << endl;
}
0