結果

問題 No.2732 Similar Permutations
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2024-04-25 16:40:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,486 bytes
コンパイル時間 2,356 ms
コンパイル使用メモリ 201,824 KB
実行使用メモリ 17,100 KB
最終ジャッジ日時 2024-04-25 16:41:01
合計ジャッジ時間 27,944 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
16,176 KB
testcase_01 AC 6 ms
16,168 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 WA -
testcase_06 WA -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 RE -
testcase_51 RE -
testcase_52 RE -
testcase_53 RE -
testcase_54 RE -
testcase_55 RE -
testcase_56 RE -
testcase_57 RE -
testcase_58 RE -
testcase_59 RE -
testcase_60 RE -
testcase_61 RE -
testcase_62 RE -
testcase_63 AC 8 ms
16,168 KB
testcase_64 AC 6 ms
16,112 KB
testcase_65 AC 5 ms
16,148 KB
testcase_66 AC 6 ms
15,980 KB
testcase_67 AC 8 ms
15,976 KB
testcase_68 AC 6 ms
16,272 KB
testcase_69 AC 5 ms
16,200 KB
testcase_70 AC 6 ms
16,040 KB
testcase_71 AC 5 ms
16,188 KB
testcase_72 AC 5 ms
16,088 KB
testcase_73 AC 5 ms
16,196 KB
testcase_74 AC 7 ms
16,228 KB
testcase_75 AC 5 ms
16,084 KB
testcase_76 AC 6 ms
16,200 KB
testcase_77 AC 5 ms
16,092 KB
testcase_78 AC 5 ms
16,096 KB
testcase_79 AC 6 ms
16,084 KB
testcase_80 AC 6 ms
16,116 KB
testcase_81 AC 5 ms
16,268 KB
testcase_82 AC 6 ms
16,228 KB
testcase_83 AC 6 ms
16,156 KB
testcase_84 AC 6 ms
16,116 KB
testcase_85 AC 6 ms
16,152 KB
testcase_86 AC 6 ms
16,112 KB
testcase_87 AC 5 ms
16,092 KB
testcase_88 AC 4 ms
16,084 KB
testcase_89 AC 4 ms
15,980 KB
testcase_90 AC 6 ms
16,260 KB
testcase_91 AC 6 ms
16,152 KB
testcase_92 AC 6 ms
16,084 KB
testcase_93 AC 6 ms
15,980 KB
testcase_94 AC 5 ms
16,164 KB
testcase_95 AC 7 ms
16,276 KB
testcase_96 AC 6 ms
16,268 KB
testcase_97 AC 6 ms
16,092 KB
testcase_98 AC 7 ms
16,176 KB
testcase_99 AC 6 ms
16,108 KB
testcase_100 AC 6 ms
16,176 KB
testcase_101 AC 6 ms
16,108 KB
testcase_102 AC 6 ms
16,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    //500000<=2^19-1=524287
    //総XORは524287以下
    //最初の10項を並び替えるだけで3628800通りの値が作れる
    
    int N, S;
    cin >> N;
    vector<int> A(N);
    for (int i=0; i<N; i++) cin >> A[i];
    vector<int> p(min(N, 10));
    iota(p.begin(), p.end(), 1);
    vector<vector<int>> v(550000);

    if (N<=9){
        do{
            S = 0;
            for (int i=0; i<N; i++){
                S ^= p[i]+A[i];
            }
            if (v[S].size() == 0) v[S] = p;
            else{
                for (auto x : p) cout << x << " ";
                cout << endl;
                for (auto x : v[S]) cout << x << " ";
                cout << endl;
                return 0;
            }
        } while(next_permutation(p.begin(), p.end()));
        cout << -1 << endl;
        return 0;
    }
    do{
        S = 0;
        for (int i=0; i<N; i++){
            S ^= p[i]+A[i];
        }
        if (v[S].size() == 0) v[S] = p;
        else{
            for (auto x : p) cout << x << " ";
            for (int i=11; i<=N; i++) cout << i << " ";
            cout << endl;
            for (auto x : v[S]) cout << x << " ";
            for (int i=11; i<=N; i++) cout << i << " ";
            cout << endl;
            return 0;
        }
    } while(next_permutation(p.begin(), p.end()));

    return 0;
}
0