結果

問題 No.2732 Similar Permutations
ユーザー pitPpitP
提出日時 2024-04-20 00:03:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 2,974 bytes
コンパイル時間 4,083 ms
コンパイル使用メモリ 263,352 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 00:03:42
合計ジャッジ時間 17,623 ms
ジャッジサーバーID
(参考情報)
judge6 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 14 ms
5,248 KB
testcase_03 AC 25 ms
5,376 KB
testcase_04 AC 10 ms
5,376 KB
testcase_05 AC 7 ms
5,376 KB
testcase_06 AC 4 ms
5,376 KB
testcase_07 AC 20 ms
5,376 KB
testcase_08 AC 11 ms
5,376 KB
testcase_09 AC 6 ms
5,376 KB
testcase_10 AC 44 ms
5,376 KB
testcase_11 AC 5 ms
5,376 KB
testcase_12 AC 48 ms
5,376 KB
testcase_13 AC 45 ms
5,376 KB
testcase_14 AC 49 ms
5,376 KB
testcase_15 AC 45 ms
5,376 KB
testcase_16 AC 33 ms
5,376 KB
testcase_17 AC 32 ms
5,376 KB
testcase_18 AC 44 ms
5,376 KB
testcase_19 AC 48 ms
5,376 KB
testcase_20 AC 45 ms
5,376 KB
testcase_21 AC 46 ms
5,376 KB
testcase_22 AC 26 ms
5,376 KB
testcase_23 AC 46 ms
5,376 KB
testcase_24 AC 27 ms
5,376 KB
testcase_25 AC 45 ms
5,376 KB
testcase_26 AC 38 ms
5,376 KB
testcase_27 AC 46 ms
5,376 KB
testcase_28 AC 37 ms
5,376 KB
testcase_29 AC 46 ms
5,376 KB
testcase_30 AC 32 ms
5,376 KB
testcase_31 AC 47 ms
5,376 KB
testcase_32 AC 43 ms
5,376 KB
testcase_33 AC 45 ms
5,376 KB
testcase_34 AC 31 ms
5,376 KB
testcase_35 AC 48 ms
5,376 KB
testcase_36 AC 45 ms
5,376 KB
testcase_37 AC 45 ms
5,376 KB
testcase_38 AC 40 ms
5,376 KB
testcase_39 AC 46 ms
5,376 KB
testcase_40 AC 38 ms
5,376 KB
testcase_41 AC 46 ms
5,376 KB
testcase_42 AC 34 ms
5,376 KB
testcase_43 AC 46 ms
5,376 KB
testcase_44 AC 24 ms
5,376 KB
testcase_45 AC 46 ms
5,376 KB
testcase_46 AC 41 ms
5,376 KB
testcase_47 AC 45 ms
5,376 KB
testcase_48 AC 28 ms
5,376 KB
testcase_49 AC 45 ms
5,376 KB
testcase_50 AC 27 ms
5,376 KB
testcase_51 AC 44 ms
5,376 KB
testcase_52 AC 37 ms
5,376 KB
testcase_53 AC 45 ms
5,376 KB
testcase_54 AC 48 ms
5,376 KB
testcase_55 AC 47 ms
5,376 KB
testcase_56 AC 47 ms
5,376 KB
testcase_57 AC 25 ms
5,376 KB
testcase_58 AC 32 ms
5,376 KB
testcase_59 AC 33 ms
5,376 KB
testcase_60 AC 27 ms
5,376 KB
testcase_61 AC 25 ms
5,376 KB
testcase_62 AC 40 ms
5,376 KB
testcase_63 AC 2 ms
5,376 KB
testcase_64 AC 2 ms
5,376 KB
testcase_65 AC 1 ms
5,376 KB
testcase_66 AC 2 ms
5,376 KB
testcase_67 AC 1 ms
5,376 KB
testcase_68 AC 1 ms
5,376 KB
testcase_69 AC 1 ms
5,376 KB
testcase_70 AC 1 ms
5,376 KB
testcase_71 AC 1 ms
5,376 KB
testcase_72 AC 2 ms
5,376 KB
testcase_73 AC 1 ms
5,376 KB
testcase_74 AC 1 ms
5,376 KB
testcase_75 AC 1 ms
5,376 KB
testcase_76 AC 1 ms
5,376 KB
testcase_77 AC 2 ms
5,376 KB
testcase_78 AC 2 ms
5,376 KB
testcase_79 AC 2 ms
5,376 KB
testcase_80 AC 1 ms
5,376 KB
testcase_81 AC 1 ms
5,376 KB
testcase_82 AC 2 ms
5,376 KB
testcase_83 AC 1 ms
5,376 KB
testcase_84 AC 1 ms
5,376 KB
testcase_85 AC 1 ms
5,376 KB
testcase_86 AC 1 ms
5,376 KB
testcase_87 AC 1 ms
5,376 KB
testcase_88 AC 1 ms
5,376 KB
testcase_89 AC 2 ms
5,376 KB
testcase_90 AC 1 ms
5,376 KB
testcase_91 AC 1 ms
5,376 KB
testcase_92 AC 1 ms
5,376 KB
testcase_93 AC 1 ms
5,376 KB
testcase_94 AC 1 ms
5,376 KB
testcase_95 AC 1 ms
5,376 KB
testcase_96 AC 2 ms
5,376 KB
testcase_97 AC 2 ms
5,376 KB
testcase_98 AC 1 ms
5,376 KB
testcase_99 AC 1 ms
5,376 KB
testcase_100 AC 1 ms
5,376 KB
testcase_101 AC 1 ms
5,376 KB
testcase_102 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
istream &operator>>(istream &is, modint &a) { long long v; is >> v; a = v; return is; }
ostream &operator<<(ostream &os, const modint &a) { return os << a.val(); }
istream &operator>>(istream &is, modint998244353 &a) { long long v; is >> v; a = v; return is; }
ostream &operator<<(ostream &os, const modint998244353 &a) { return os << a.val(); }
istream &operator>>(istream &is, modint1000000007 &a) { long long v; is >> v; a = v; return is; }
ostream &operator<<(ostream &os, const modint1000000007 &a) { return os << a.val(); } 

typedef long long ll;
typedef vector<vector<int>> Graph;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define FOR(i,l,r) for (int i = l;i < (int)(r); i++)
#define rep(i,n) for (int i = 0;i < (int)(n); i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define my_sort(x) sort(x.begin(), x.end())
#define my_max(x) *max_element(all(x))
#define my_min(x) *min_element(all(x))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<62) - 1;
const int MOD = 998244353;
const int MOD2 = 1e9+7;
const double PI = acos(-1);
vector<int> di = {1,0,-1,0};
vector<int> dj = {0,1,0,-1};

#ifdef LOCAL
#  include <debug_print.hpp>
#  define debug(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#  define debug(...) (static_cast<void>(0))
#endif

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    map<int, vector<int>> mp;
    if(N <= 9){
        vector<int> p(N);
        iota(all(p), 1);
        do{
            int x = 0;
            rep(i,N) x ^= (A[i] + p[i]);
            if(mp.find(x)!=mp.end()){
                rep(i,N) cout << mp[x][i] << (i == N - 1 ? "\n" : " ");
                rep(i,N) cout << p[i] << (i == N - 1 ? "\n" : " ");
                return 0;
            }
            mp[x] = p;
        } while (next_permutation(all(p)));
        cout << -1 << endl;
    }
    else{
        vector<int> p(10);
        iota(all(p), 1);
        do{
            int x = 0;
            rep(i,N) {
                if(i < 10) x ^= (A[i] + p[i]);
                else x ^= (A[i] + i + 1);
            }
            if(mp.find(x)!=mp.end()){
                rep(i,N) {
                    if(i < 10) cout << mp[x][i] << (i == N - 1 ? "\n" : " ");
                    else cout << i + 1 << (i == N - 1 ? "\n" : " ");
                }
                rep(i,N) {
                    if(i < 10) cout << p[i] << (i == N - 1 ? "\n" : " ");
                    else cout << i + 1 << (i == N - 1 ? "\n" : " ");
                }
                return 0;
            }
            mp[x] = p;
        } while (next_permutation(all(p)));
    }
}
0