結果
問題 | No.2732 Similar Permutations |
ユーザー | Today03 |
提出日時 | 2024-04-19 22:40:47 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 104 ms / 2,000 ms |
コード長 | 7,101 bytes |
コンパイル時間 | 3,011 ms |
コンパイル使用メモリ | 234,732 KB |
実行使用メモリ | 8,576 KB |
最終ジャッジ日時 | 2024-10-11 16:25:38 |
合計ジャッジ時間 | 20,200 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 30 ms
5,248 KB |
testcase_03 | AC | 55 ms
5,248 KB |
testcase_04 | AC | 20 ms
5,248 KB |
testcase_05 | AC | 14 ms
5,248 KB |
testcase_06 | AC | 7 ms
5,248 KB |
testcase_07 | AC | 42 ms
5,376 KB |
testcase_08 | AC | 21 ms
5,248 KB |
testcase_09 | AC | 11 ms
5,248 KB |
testcase_10 | AC | 101 ms
8,576 KB |
testcase_11 | AC | 9 ms
5,248 KB |
testcase_12 | AC | 102 ms
5,632 KB |
testcase_13 | AC | 100 ms
5,632 KB |
testcase_14 | AC | 102 ms
5,760 KB |
testcase_15 | AC | 99 ms
5,760 KB |
testcase_16 | AC | 74 ms
5,632 KB |
testcase_17 | AC | 71 ms
5,376 KB |
testcase_18 | AC | 95 ms
6,272 KB |
testcase_19 | AC | 100 ms
5,504 KB |
testcase_20 | AC | 103 ms
6,400 KB |
testcase_21 | AC | 101 ms
5,632 KB |
testcase_22 | AC | 59 ms
5,248 KB |
testcase_23 | AC | 101 ms
6,528 KB |
testcase_24 | AC | 60 ms
5,248 KB |
testcase_25 | AC | 104 ms
6,400 KB |
testcase_26 | AC | 83 ms
5,248 KB |
testcase_27 | AC | 103 ms
6,400 KB |
testcase_28 | AC | 81 ms
5,248 KB |
testcase_29 | AC | 101 ms
6,400 KB |
testcase_30 | AC | 73 ms
5,248 KB |
testcase_31 | AC | 101 ms
5,632 KB |
testcase_32 | AC | 94 ms
5,376 KB |
testcase_33 | AC | 101 ms
5,632 KB |
testcase_34 | AC | 67 ms
5,248 KB |
testcase_35 | AC | 101 ms
5,632 KB |
testcase_36 | AC | 93 ms
5,376 KB |
testcase_37 | AC | 102 ms
5,632 KB |
testcase_38 | AC | 87 ms
5,248 KB |
testcase_39 | AC | 101 ms
5,632 KB |
testcase_40 | AC | 83 ms
5,248 KB |
testcase_41 | AC | 101 ms
5,760 KB |
testcase_42 | AC | 76 ms
5,248 KB |
testcase_43 | AC | 99 ms
5,632 KB |
testcase_44 | AC | 52 ms
5,248 KB |
testcase_45 | AC | 99 ms
5,504 KB |
testcase_46 | AC | 89 ms
5,376 KB |
testcase_47 | AC | 98 ms
5,760 KB |
testcase_48 | AC | 60 ms
5,248 KB |
testcase_49 | AC | 96 ms
5,504 KB |
testcase_50 | AC | 59 ms
5,248 KB |
testcase_51 | AC | 88 ms
5,632 KB |
testcase_52 | AC | 77 ms
5,376 KB |
testcase_53 | AC | 104 ms
7,168 KB |
testcase_54 | AC | 103 ms
6,528 KB |
testcase_55 | AC | 102 ms
5,760 KB |
testcase_56 | AC | 101 ms
5,760 KB |
testcase_57 | AC | 54 ms
5,632 KB |
testcase_58 | AC | 73 ms
6,528 KB |
testcase_59 | AC | 67 ms
5,760 KB |
testcase_60 | AC | 58 ms
5,376 KB |
testcase_61 | AC | 52 ms
5,248 KB |
testcase_62 | AC | 86 ms
6,400 KB |
testcase_63 | AC | 2 ms
5,248 KB |
testcase_64 | AC | 2 ms
5,248 KB |
testcase_65 | AC | 2 ms
5,248 KB |
testcase_66 | AC | 2 ms
5,248 KB |
testcase_67 | AC | 2 ms
5,248 KB |
testcase_68 | AC | 2 ms
5,248 KB |
testcase_69 | AC | 2 ms
5,248 KB |
testcase_70 | AC | 2 ms
5,248 KB |
testcase_71 | AC | 2 ms
5,248 KB |
testcase_72 | AC | 2 ms
5,248 KB |
testcase_73 | AC | 2 ms
5,248 KB |
testcase_74 | AC | 2 ms
5,248 KB |
testcase_75 | AC | 2 ms
5,248 KB |
testcase_76 | AC | 2 ms
5,248 KB |
testcase_77 | AC | 2 ms
5,248 KB |
testcase_78 | AC | 2 ms
5,248 KB |
testcase_79 | AC | 2 ms
5,248 KB |
testcase_80 | AC | 2 ms
5,248 KB |
testcase_81 | AC | 1 ms
5,248 KB |
testcase_82 | AC | 2 ms
5,248 KB |
testcase_83 | AC | 1 ms
5,248 KB |
testcase_84 | AC | 2 ms
5,248 KB |
testcase_85 | AC | 2 ms
5,248 KB |
testcase_86 | AC | 2 ms
5,248 KB |
testcase_87 | AC | 2 ms
5,248 KB |
testcase_88 | AC | 2 ms
5,248 KB |
testcase_89 | AC | 2 ms
5,248 KB |
testcase_90 | AC | 2 ms
5,248 KB |
testcase_91 | AC | 2 ms
5,248 KB |
testcase_92 | AC | 2 ms
5,248 KB |
testcase_93 | AC | 2 ms
5,248 KB |
testcase_94 | AC | 2 ms
5,248 KB |
testcase_95 | AC | 2 ms
5,248 KB |
testcase_96 | AC | 2 ms
5,248 KB |
testcase_97 | AC | 2 ms
5,248 KB |
testcase_98 | AC | 2 ms
5,248 KB |
testcase_99 | AC | 2 ms
5,248 KB |
testcase_100 | AC | 2 ms
5,248 KB |
testcase_101 | AC | 2 ms
5,248 KB |
testcase_102 | AC | 2 ms
5,248 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; const int INF = 1e9 + 10; const ll INFL = 4e18; namespace random_generator { mt19937_64 generate; void init() { random_device seed_gen; generate = mt19937_64(seed_gen()); } template <typename T> T random_int(T x) { assert(x > 0); return generate() % x; } template <typename T> T random_int(T x, T y) { assert(x < y); return x + generate() % (y - x); } template <typename T> T get_elememt(vector<T>& a) { const int n = a.size(); int idx = random_int(0, n); swap(a[n - 1], a[idx]); int ret = a.back(); a.pop_back(); return ret; } template <typename T> vector<T> random_array_int(int n, T lo, T hi, bool no_dup = false) { vector<T> ret(n); if (!no_dup) { for (int i = 0; i < n; i++) { ret[i] = random_int(lo, hi); } } else { set<T> st; for (int i = 0; i < n; i++) { int r = random_int(lo, hi); while (st.count(r)) { r = random_int(lo, hi); } ret[i] = r; st.insert(r); } } return ret; } string random_alphabet(int n, bool lower = true) { string ret; for (int i = 0; i < n; i++) { int idx = random_int(26); ret.push_back(char((lower ? 'a' : 'A') + idx)); } return ret; } string random_string(int n, string s) { string ret; int m = s.size(); for (int i = 0; i < n; i++) { int idx = random_int(m); ret.push_back(s[idx]); } return ret; } template <typename T> vector<vector<T>> random_array_2D(int h, int w, T lo, T hi) { vector<vector<T>> ret(h, vector<T>(w)); for (int i = 0; i < h; i++) { ret[i] = random_array_int(w, lo, hi); } return ret; } vector<string> random_alphabet_2D(int h, int w, bool lower = true) { vector<string> ret(h); for (int i = 0; i < h; i++) { ret[i] = random_alphabet(w, lower); } return ret; } vector<pair<int, int>> random_tree(int n) { vector<int> a = random_array_int<int>(n - 2, 1, n + 1); vector<int> d(n + 1); for (int i = 0; i < n - 2; i++) { d[a[i]]++; } for (int i = 1; i <= n; i++) { d[i]++; } vector<pair<int, int>> ret; set<int> pq; for (int i = 1; i <= n; i++) { if (d[i] == 1) { pq.insert(i); } } for (int i = 0; i < n - 2; i++) { int v = (*pq.begin()); pq.erase(v); ret.push_back(make_pair(v, a[i])); d[v]--; d[a[i]]--; if (d[a[i]] == 1) { pq.insert(a[i]); } else if (d[a[i]] == 0) { pq.erase(a[i]); } } for (int i = 1; i <= n; i++) { if (d[i] == 1) { for (int j = i + 1; j <= n; j++) { if (d[j] == 1) { ret.push_back(make_pair(i, j)); break; } } break; } } return ret; } vector<pair<int, int>> random_bintree(int n) { vector<pair<int, int>> ret; vector<ll> roots = {random_int(1, n + 1)}; vector<ll> leaves; for (int i = 1; i <= n; i++) { if (i != roots.back()) { leaves.push_back(i); } } while (!leaves.empty()) { int root = get_elememt(roots); int leaf = get_elememt(leaves); ret.push_back(make_pair(root, leaf)); roots.push_back(leaf); if (!leaves.empty()) { int leaf = get_elememt(leaves); ret.push_back(make_pair(root, leaf)); roots.push_back(leaf); } } return ret; } vector<pair<int, int>> random_undigraph(int n, int m, bool connected = true) { vector<pair<int, int>> edges; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { edges.push_back(make_pair(i + 1, j + 1)); } } int ed = edges.size(); if (!connected) { vector<pair<int, int>> ret; vector<int> idxs = random_array_int<int>(m, 0, ed, true); for (int idx : idxs) { ret.push_back(edges[idx]); } return ret; } else { vector<pair<int, int>> ret; while (true) { ret.clear(); vector<int> idxs = random_array_int<int>(m, 0, ed, true); vector<int> parent(n); vector<vector<int>> sets(n); for (int i = 0; i < n; i++) { parent[i] = i; sets[i].push_back(i); } for (int idx : idxs) { ret.push_back(edges[idx]); auto [a, b] = edges[idx]; a--; b--; if (parent[a] != parent[b]) { if (sets[parent[a]].size() < sets[parent[b]].size()) { swap(a, b); } for (int x : sets[parent[b]]) { parent[x] = parent[a]; sets[parent[a]].push_back(x); } sets[parent[b]].clear(); } } bool ok = true; for (int i = 0; i < n; i++) { if (parent[i] != parent[0]) { ok = false; break; } } if (ok) { return ret; } } } } }; // namespace random_generator struct setup_random { setup_random() { random_generator::init(); } } setup_random_instance; int main() { int N; cin >> N; vector<int> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } vector<int> P(N); iota(P.begin(), P.end(), 1); map<int, vector<int>> mp; do { int xorsum = 0; for (int i = 0; i < N; i++) { xorsum ^= (A[i] + P[i]); } if (mp.find(xorsum) != mp.end()) { for (int i = 0; i < N; i++) { cout << mp[xorsum][i] << " "; } cout << endl; for (int i = 0; i < N; i++) { cout << P[i] << " "; } cout << endl; return 0; } else { mp[xorsum] = P; } } while (next_permutation(P.begin(), P.end())); cout << -1 << endl; }