結果

問題 No.2732 Similar Permutations
ユーザー 唐揚げが壊わ唐揚げが壊わ
提出日時 2024-04-20 02:18:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 9,177 bytes
コンパイル時間 2,899 ms
コンパイル使用メモリ 225,544 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-11 21:11:37
合計ジャッジ時間 21,187 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,820 KB
testcase_02 AC 30 ms
6,816 KB
testcase_03 AC 56 ms
6,820 KB
testcase_04 AC 19 ms
6,820 KB
testcase_05 AC 14 ms
6,820 KB
testcase_06 AC 7 ms
6,820 KB
testcase_07 AC 42 ms
6,816 KB
testcase_08 AC 22 ms
6,820 KB
testcase_09 AC 12 ms
6,816 KB
testcase_10 AC 97 ms
6,816 KB
testcase_11 AC 9 ms
6,820 KB
testcase_12 AC 100 ms
6,820 KB
testcase_13 AC 99 ms
6,816 KB
testcase_14 AC 100 ms
6,820 KB
testcase_15 AC 100 ms
6,816 KB
testcase_16 AC 71 ms
6,816 KB
testcase_17 AC 70 ms
6,820 KB
testcase_18 AC 92 ms
6,820 KB
testcase_19 AC 100 ms
6,820 KB
testcase_20 AC 99 ms
6,816 KB
testcase_21 AC 102 ms
6,820 KB
testcase_22 AC 57 ms
6,816 KB
testcase_23 AC 100 ms
6,820 KB
testcase_24 AC 59 ms
6,820 KB
testcase_25 AC 99 ms
6,820 KB
testcase_26 AC 84 ms
6,820 KB
testcase_27 AC 100 ms
6,816 KB
testcase_28 AC 79 ms
6,816 KB
testcase_29 AC 101 ms
6,816 KB
testcase_30 AC 73 ms
6,820 KB
testcase_31 AC 101 ms
6,820 KB
testcase_32 AC 93 ms
6,820 KB
testcase_33 AC 100 ms
6,816 KB
testcase_34 AC 66 ms
6,816 KB
testcase_35 AC 99 ms
6,816 KB
testcase_36 AC 96 ms
6,820 KB
testcase_37 AC 100 ms
6,816 KB
testcase_38 AC 87 ms
6,820 KB
testcase_39 AC 99 ms
6,820 KB
testcase_40 AC 83 ms
6,816 KB
testcase_41 AC 99 ms
6,820 KB
testcase_42 AC 74 ms
6,816 KB
testcase_43 AC 98 ms
6,816 KB
testcase_44 AC 53 ms
6,816 KB
testcase_45 AC 97 ms
6,820 KB
testcase_46 AC 88 ms
6,820 KB
testcase_47 AC 96 ms
6,816 KB
testcase_48 AC 60 ms
6,816 KB
testcase_49 AC 94 ms
6,816 KB
testcase_50 AC 57 ms
6,816 KB
testcase_51 AC 89 ms
6,816 KB
testcase_52 AC 77 ms
6,820 KB
testcase_53 AC 99 ms
6,816 KB
testcase_54 AC 99 ms
6,816 KB
testcase_55 AC 100 ms
6,816 KB
testcase_56 AC 100 ms
6,816 KB
testcase_57 AC 52 ms
6,820 KB
testcase_58 AC 70 ms
6,816 KB
testcase_59 AC 66 ms
6,816 KB
testcase_60 AC 57 ms
6,820 KB
testcase_61 AC 52 ms
6,820 KB
testcase_62 AC 83 ms
6,816 KB
testcase_63 AC 2 ms
6,816 KB
testcase_64 AC 2 ms
6,820 KB
testcase_65 AC 2 ms
6,820 KB
testcase_66 AC 2 ms
6,816 KB
testcase_67 AC 2 ms
6,816 KB
testcase_68 AC 2 ms
6,816 KB
testcase_69 AC 2 ms
6,816 KB
testcase_70 AC 2 ms
6,816 KB
testcase_71 AC 2 ms
6,816 KB
testcase_72 AC 2 ms
6,816 KB
testcase_73 AC 2 ms
6,820 KB
testcase_74 AC 2 ms
6,816 KB
testcase_75 AC 2 ms
6,820 KB
testcase_76 AC 2 ms
6,820 KB
testcase_77 AC 2 ms
6,820 KB
testcase_78 AC 2 ms
6,820 KB
testcase_79 AC 2 ms
6,816 KB
testcase_80 AC 2 ms
6,816 KB
testcase_81 AC 2 ms
6,820 KB
testcase_82 AC 2 ms
6,820 KB
testcase_83 AC 2 ms
6,816 KB
testcase_84 AC 2 ms
6,816 KB
testcase_85 AC 2 ms
6,816 KB
testcase_86 AC 2 ms
6,816 KB
testcase_87 AC 2 ms
6,820 KB
testcase_88 AC 2 ms
6,816 KB
testcase_89 AC 2 ms
6,816 KB
testcase_90 AC 2 ms
6,816 KB
testcase_91 AC 2 ms
6,820 KB
testcase_92 AC 2 ms
6,816 KB
testcase_93 AC 2 ms
6,820 KB
testcase_94 AC 2 ms
6,816 KB
testcase_95 AC 2 ms
6,820 KB
testcase_96 AC 2 ms
6,820 KB
testcase_97 AC 2 ms
6,816 KB
testcase_98 AC 2 ms
6,816 KB
testcase_99 AC 2 ms
6,820 KB
testcase_100 AC 2 ms
6,820 KB
testcase_101 AC 2 ms
6,816 KB
testcase_102 AC 2 ms
6,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

// #include <atcoder/all>

// Ctrl + end

using namespace std;
using str = string;
using vs = vector<string>;
using ll = long long;
using ld = long double;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vvvll = vector<vector<vector<long long>>>;
using vvvvll = vector<vector<vector<vector<long long>>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using pll = pair<ll, ll>;
using vpll = vector<pair<ll, ll>>;

#define REP1(i, n) for (long long i = 0; i < n; i++)
#define REP2(i, n, m) for (long long i = n; i < m; i++)
#define REP3(i, n, d, m) \
  for (long long i = n; (n < m) ? (i < m) : (i > m); i += d)
#define OVERLOAD_REP(a, b, c, d, e, ...) e
#define REP(...) OVERLOAD_REP(__VA_ARGS__, REP3, REP2, REP1)(__VA_ARGS__)

#define REPv(itr, v) for (auto itr = v.begin(); itr != v.end(); itr++)

#define REPIN(itr, v)                                 \
  for (auto itr = v.begin(); itr != v.end(); itr++) { \
    cin >> *itr;                                      \
  }
#define been(vec) vec.begin(), vec.end()
#define LIN                   \
  = []() {                    \
    long long LONGLONG_INPUT; \
    cin >> LONGLONG_INPUT;    \
    return LONGLONG_INPUT;    \
  }()
#define SIN              \
  = []() {               \
    string STRING_INPUT; \
    cin >> STRING_INPUT; \
    return STRING_INPUT; \
  }()
#define SPNL(i, SIZE) (i + 1 == SIZE ? '\n' : ' ')

template <class T>
constexpr T gcd(const T &x, const T &y) {
  return (x % y) ? gcd(y, x % y) : y;
}
template <class T, class... R>
constexpr T gcd(const T &x, const R &...y) {
  return gcd(x, gcd(y...));
}
template <class T>
constexpr T lcm(const T &x, const T &y) {
  return x / gcd(x, y) * y;
}
template <class T, class... R>
constexpr T lcm(const T &x, const R &...y) {
  return lcm(x, lcm(y...));
}

template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

// 3要素で比較するとfunc(a,b,comp)と勘違いされるから「{...}」使う
template <class... T>
constexpr auto min(const T &...a) {
  return min(initializer_list<common_type_t<T...>>{a...});
}
template <class... T>
constexpr auto max(const T &...a) {
  return max(initializer_list<common_type_t<T...>>{a...});
}

// tuple処理
template <size_t N = 0, class T, class F>
void iterate_tuple(T &t, const F &func) {
  if constexpr (N < tuple_size_v<T>) {
    auto &x = get<N>(t);
    func(x);
    iterate_tuple<N + 1>(t, func);
  }
}

// ストリーム演算子 入力
template <class T1, class T2>
istream &operator>>(istream &is, pair<T1, T2> &p) {
  is >> p.first >> p.second;
  return is;
}
template <class... T>
istream &operator>>(istream &is, tuple<T...> &t) {
  auto func = [&is](auto &t) { is >> t; };
  iterate_tuple(t, func);
  return is;
}
template <class T>
istream &operator>>(istream &is, vector<T> &v) {
  for (size_t i = 0, n = v.size(); i < n; i++) {
    is >> v[i];
  }
  return is;
}

// ストリーム演算子 出力
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << p.first << " " << p.second << " ";
  return os;
}
template <class... T>
ostream &operator<<(ostream &os, const tuple<T...> &t) {
  auto func = [&os](auto t) { os << t << " "; };
  iterate_tuple(t, func);
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (size_t i = 0, n = v.size(); i < n; i++) {
    os << v[i] << " ";
  }
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const vector<vector<T>> &v) {
  for (size_t i = 0, n = v.size(); i < n; i++) {
    os << v[i] << endl;
  }
  return os;
}
template <class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    os << "[" << itr->first << "]" << itr->second << endl;
  }
  return os;
}
template <class T1, class T2>
ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp) {
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    os << "[" << itr->first << "]" << itr->second << endl;
  }
  return os;
}

template <class T>
void input(T &a) {
  cin >> a;
}
template <class T, class... R>
void input(T &a, R &...b) {
  input(a), input(b...);
}

template <class... T>
constexpr void output(const T &...a) {
  (cout << ... << (cout << a, " "));
  cout << endl;
}

template <class T1, class T2>
pair<T1, T2> operator+(const pair<T1, T2> &a, const pair<T1, T2> &b) {
  pair<T1, T2> ret;
  ret = make_pair(a.first + b.first, a.second + b.second);
  return ret;
}
template <class T1, class T2, class T3>
pair<T1, T2> operator+(const pair<T1, T2> &a, const T3 &b) {
  pair<T1, T2> ret;
  ret = make_pair(a.first + b, a.second + b);
  return ret;
}
template <class T1, class T2>
pair<T1, T2> operator-(const pair<T1, T2> &a, const pair<T1, T2> &b) {
  pair<T1, T2> ret;
  ret = make_pair(a.first - b.first, a.second - b.second);
  return ret;
}
template <class T1, class T2, class T3>
pair<T1, T2> operator-(const pair<T1, T2> &a, const T3 &b) {
  pair<T1, T2> ret;
  ret = make_pair(a.first - b, a.second - b);
  return ret;
}
template <class T>
vector<T> operator+(const vector<T> &a, const vector<T> &b) {
  // aとbのサイズは一致する必要がある。
  assert(a.size() == b.size());
  vector<T> ret = a;
  for (size_t i = 0; i < ret.size(); i++) {
    ret[i] = a[i] + b[i];
  }
  return ret;
}
template <class T1, class T2>
vector<T1> operator+(const vector<T1> &a, const T2 &b) {
  vector<T1> ret = a;
  for (size_t i = 0; i < ret.size(); i++) {
    ret[i] = a[i] + b;
  }
  return ret;
}

// 二次元配列aを右回転する
template <class T>
constexpr vector<vector<T>> rotate_90deg(const vector<vector<T>> &a) {
  vector<vector<T>> b(a.front().size(), vector<T>(a.size()));
  for (size_t i = 0; i < a.front().size(); i++) {
    for (size_t j = 0; j < a.size(); j++) {
      b[i][j] = (a[a.size() - 1 - j][i]);
    }
  }
  return b;
}
// 二次元配列aをelementで指定した要素を含み切るようにクリッピング
vector<string> clip_vec2(const vector<string> &a, const char element) {
  ll left = LLONG_MAX, right = -1, top = LLONG_MAX, bottom = -1;
  for (size_t i = 0; i < a.size(); i++) {
    for (size_t j = 0; j < a.front().size(); j++) {
      if (a[i][j] == element) {
        chmin(top, (ll)i);
        chmax(bottom, (ll)i);
        chmin(left, (ll)j);
        chmax(right, (ll)j);
      }
    }
  }
  vector<string> b(abs(bottom - top), string(abs(right - left), ' '));
  for (size_t i = 0; i < b.size(); i++) {
    for (size_t j = 0; j < b.front().size(); j++) {
      b[i][j] = a[i + top][j + left];
    }
  }
  return b;
}
template <class T>
constexpr vector<vector<T>> clip_vec2(const vector<vector<T>> &a,
                                      const T element) {
  ll left = LLONG_MAX, right = -1, top = LLONG_MAX, bottom = -1;
  for (size_t i = 0; i < a.size(); i++) {
    for (size_t j = 0; j < a.front().size(); j++) {
      if (a[i][j] == element) {
        chmin(top, (ll)i);
        chmax(bottom, (ll)i);
        chmin(left, (ll)j);
        chmax(right, (ll)j);
      }
    }
  }
  vector<vector<T>> b(abs(bottom - top), vector<T>(abs(right - left)));
  for (size_t i = 0; i < b.size(); i++) {
    for (size_t j = 0; j < b.front().size(); j++) {
      b[i][j] = a[i + top][j + left];
    }
  }
  return b;
}
// 二次元配列aをelementで指定した要素で囲い込む
vector<string> envelope_vec2(const vector<string> &a, const char element) {
  vector<string> b = a;
  for (size_t i = 0; i < b.size(); i++) {
    b[i].insert(b[i].end(), {element, element});
    std::rotate(b[i].rbegin(), b[i].rbegin() + 1, b[i].rend());
  }
  b.push_back(string(b[0].size(), element));
  b.push_back(b.back());
  std::rotate(b.rbegin(), b.rbegin() + 1, b.rend());
  return b;
}
template <class T>
constexpr vector<vector<T>> envelope_vec2(const vector<vector<T>> &a,
                                          const T element) {
  vector<vector<T>> b = a;
  for (size_t i = 0; i < b.size(); i++) {
    b[i].insert(b[i].end(), {element, element});
    std::rotate(b[i].rbegin(), b[i].rbegin() + 1, b[i].rend());
  }
  b.push_back(vector<T>(b[0].size(), element));
  b.push_back(b.back());
  std::rotate(b.rbegin(), b.rbegin() + 1, b.rend());
  return b;
}

const long long mod1000 = 1000000007;
const long long mod998 = 998244353;
const string yes = "Yes";
const string no = "No";

int main() {
  ll n LIN;
  vll a(n);
  input(a);

  vll p(min(10, n));
  REP(i, p.size()) p[i] = i + 1;

  map<ll, vll> mp;

  do {
    ll sum = 0;
    REP(i, p.size()) { sum ^= (p[i] + a[i]); }
    if (mp.count(sum)) {
      REP(i, n) {
        if (i < p.size())
          cout << p[i] << " ";
        else
          cout << i + 1 << " ";
      }
      cout << endl;
      REP(i, n) {
        if (i < mp[sum].size())
          cout << mp[sum][i] << " ";
        else
          cout << i + 1 << " ";
      }
      cout << endl;
      exit(0);
    }
    mp[sum] = p;
  } while (next_permutation(been(p)));
  cout << -1 << endl;
}
0