結果

問題 No.2732 Similar Permutations
ユーザー ococonomy1ococonomy1
提出日時 2024-04-19 22:08:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,261 bytes
コンパイル時間 1,082 ms
コンパイル使用メモリ 117,148 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-19 22:08:28
合計ジャッジ時間 16,790 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pli = pair<ll,int>;
#define TEST cerr << "TEST" << endl
#define AMARI 998244353
//#define AMARI 1000000007
#define el '\n'
#define El '\n'

#define MULTI_TEST_CASE false
void solve(void){
    //問題を見たらまず「この問題設定から言えること」をいっぱい言う
    //一個回答に繋がりそうな解法が見えても、実装や細かい詰めに時間がかかりそうなら別の方針を考えてみる
    //添え字回りで面倒になりそうなときは楽になる言い換えを実装の前にじっくり考える
    //ある程度考察しても全然取っ掛かりが見えないときは実験をしてみる
    //よりシンプルな問題に言い換えられたら、言い換えた先の問題を自然言語ではっきりと書く
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)cin >> a[i];
    vector<int> p(n,-1),p2(n,-1);
    

    for(int i = 1; i < n; i++){
        if(a[i] % 2 == a[0] % 2){
            p[0] = 1;
            p[i] = 2;
            int cnt = 3;
            for(int j = 0; j < n; j++){
                if(j == 0 || j == i)continue;
                p[j] = cnt;
                cnt++;
            }
            p2 = p;
            swap(p2[0],p2[i]);
            for(int j = 0; j < n; j++)cout << p[j] << ' '; cout << el;
            for(int j = 0; j < n; j++)cout << p2[j] << ' '; cout << el;
            return;
        }
    }

    for(int i = 2; i < n; i++){
        if(a[i] % 2 == a[1] % 2){
            p[1] = 1;
            p[i] = 2;
            int cnt = 3;
            for(int j = 0; j < n; j++){
                if(j == 1 || j == i)continue;
                p[j] = cnt;
                cnt++;
            }
            p2 = p;
            swap(p2[1],p2[i]);
            for(int j = 0; j < n; j++)cout << p[j] << ' '; cout << el;
            for(int j = 0; j < n; j++)cout << p2[j] << ' '; cout << el;
            return;
        }
    }

    p2 = p = {1,2};
    do{
        do{
            if(p == p2)continue;
            int val1 = 0,val2 = 0;
            for(int i = 0; i < n; i++)val1 ^= (a[i] + p[i]);
            for(int i = 0; i < n; i++)val2 ^= (a[i] + p2[i]);
            if(val1 == val2){
                for(int i = 0; i < n; i++)cout << p[i] << ' ';
                cout << el;
                for(int i = 0; i < n; i++)cout << p2[i] << ' ';
                cout << el;
                return;
            }
        }while(next_permutation(p.begin(),p.end()));
    }while(next_permutation(p2.begin(),p2.end()));
    cout << -1 << el;
    return;
}

void calc(void){
    return;
}

signed main(void){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    calc();
    int t = 1;
    if(MULTI_TEST_CASE)cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
0