結果

問題 No.2732 Similar Permutations
ユーザー FplusFplusFFplusFplusF
提出日時 2024-04-05 15:05:59
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 1,688 bytes
コンパイル時間 4,594 ms
コンパイル使用メモリ 252,060 KB
実行使用メモリ 9,820 KB
最終ジャッジ日時 2024-04-05 15:06:19
合計ジャッジ時間 17,990 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 13 ms
6,548 KB
testcase_03 AC 24 ms
7,068 KB
testcase_04 AC 8 ms
6,548 KB
testcase_05 AC 7 ms
6,548 KB
testcase_06 AC 4 ms
6,548 KB
testcase_07 AC 18 ms
6,548 KB
testcase_08 AC 10 ms
6,548 KB
testcase_09 AC 6 ms
6,548 KB
testcase_10 AC 43 ms
9,572 KB
testcase_11 AC 5 ms
6,548 KB
testcase_12 AC 44 ms
9,724 KB
testcase_13 AC 43 ms
9,724 KB
testcase_14 AC 43 ms
9,724 KB
testcase_15 AC 43 ms
9,724 KB
testcase_16 AC 30 ms
8,004 KB
testcase_17 AC 30 ms
7,852 KB
testcase_18 AC 40 ms
9,216 KB
testcase_19 AC 44 ms
9,724 KB
testcase_20 AC 41 ms
9,704 KB
testcase_21 AC 45 ms
9,724 KB
testcase_22 AC 26 ms
7,104 KB
testcase_23 AC 44 ms
9,724 KB
testcase_24 AC 25 ms
7,104 KB
testcase_25 AC 42 ms
9,724 KB
testcase_26 AC 35 ms
8,688 KB
testcase_27 AC 43 ms
9,724 KB
testcase_28 AC 34 ms
8,356 KB
testcase_29 AC 42 ms
9,724 KB
testcase_30 AC 32 ms
7,992 KB
testcase_31 AC 42 ms
9,724 KB
testcase_32 AC 40 ms
9,224 KB
testcase_33 AC 42 ms
9,724 KB
testcase_34 AC 28 ms
7,516 KB
testcase_35 AC 42 ms
9,724 KB
testcase_36 AC 38 ms
9,220 KB
testcase_37 AC 44 ms
9,724 KB
testcase_38 AC 36 ms
8,876 KB
testcase_39 AC 43 ms
9,724 KB
testcase_40 AC 37 ms
8,692 KB
testcase_41 AC 42 ms
9,724 KB
testcase_42 AC 32 ms
8,172 KB
testcase_43 AC 43 ms
9,724 KB
testcase_44 AC 24 ms
6,796 KB
testcase_45 AC 43 ms
9,724 KB
testcase_46 AC 39 ms
9,188 KB
testcase_47 AC 68 ms
9,724 KB
testcase_48 AC 26 ms
7,360 KB
testcase_49 AC 45 ms
9,724 KB
testcase_50 AC 29 ms
7,232 KB
testcase_51 AC 44 ms
9,724 KB
testcase_52 AC 35 ms
8,852 KB
testcase_53 AC 44 ms
9,732 KB
testcase_54 AC 46 ms
9,796 KB
testcase_55 AC 44 ms
9,820 KB
testcase_56 AC 42 ms
9,820 KB
testcase_57 AC 22 ms
6,892 KB
testcase_58 AC 35 ms
7,940 KB
testcase_59 AC 33 ms
7,672 KB
testcase_60 AC 25 ms
7,116 KB
testcase_61 AC 24 ms
6,660 KB
testcase_62 AC 36 ms
8,776 KB
testcase_63 AC 1 ms
6,548 KB
testcase_64 AC 2 ms
6,548 KB
testcase_65 AC 2 ms
6,548 KB
testcase_66 AC 2 ms
6,548 KB
testcase_67 AC 1 ms
6,548 KB
testcase_68 AC 1 ms
6,548 KB
testcase_69 AC 2 ms
6,548 KB
testcase_70 AC 2 ms
6,548 KB
testcase_71 AC 2 ms
6,548 KB
testcase_72 AC 1 ms
6,548 KB
testcase_73 AC 2 ms
6,548 KB
testcase_74 AC 1 ms
6,548 KB
testcase_75 AC 2 ms
6,548 KB
testcase_76 AC 1 ms
6,548 KB
testcase_77 AC 2 ms
6,548 KB
testcase_78 AC 1 ms
6,548 KB
testcase_79 AC 1 ms
6,548 KB
testcase_80 AC 1 ms
6,548 KB
testcase_81 AC 2 ms
6,548 KB
testcase_82 AC 1 ms
6,548 KB
testcase_83 AC 2 ms
6,548 KB
testcase_84 AC 2 ms
6,548 KB
testcase_85 AC 1 ms
6,548 KB
testcase_86 AC 1 ms
6,548 KB
testcase_87 AC 1 ms
6,548 KB
testcase_88 AC 2 ms
6,548 KB
testcase_89 AC 1 ms
6,548 KB
testcase_90 AC 3 ms
6,548 KB
testcase_91 AC 1 ms
6,548 KB
testcase_92 AC 1 ms
6,548 KB
testcase_93 AC 2 ms
6,548 KB
testcase_94 AC 2 ms
6,548 KB
testcase_95 AC 2 ms
6,548 KB
testcase_96 AC 2 ms
6,548 KB
testcase_97 AC 2 ms
6,548 KB
testcase_98 AC 2 ms
6,548 KB
testcase_99 AC 1 ms
6,548 KB
testcase_100 AC 1 ms
6,548 KB
testcase_101 AC 2 ms
6,548 KB
testcase_102 AC 1 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
using ld=long double;
const ll INF=(1ll<<60);
#define rep(i,n) for (ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
template<class T> inline bool chmin(T &a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    if(n<=2){
        if(((a[0]+1)^(a[1]+2))==((a[0]+2)^(a[1]+1))){
            cout << "1 2\n";
            cout << "2 1\n";
        }else{
            cout << "-1\n";
        }
        return 0;
    }
    vector<ll> o,e;
    rep(i,n){
        if(a[i]&1) o.push_back(i);
        else e.push_back(i);
    }
    vector<ll> p(n),q(n);
    if(2<=(ll)o.size()){
        ll now=3;
        rep(i,n){
            if(i==o[0]){
                p[i]=1;
            }else if(i==o[1]){
                p[i]=2;
            }else{
                p[i]=now;
                now++;
            }
        }
        q=p;
        swap(q[o[0]],q[o[1]]);
    }else{
        ll now=1;
        rep(i,n){
            if(i==e[0]){
                p[i]=2;
            }else if(i==e[1]){
                p[i]=3;
            }else{
                p[i]=now;
                if(now==1) now=4;
                else now++;
            }
        }
        q=p;
        swap(q[e[0]],q[e[1]]);
    }
    rep(i,n) cout << p[i] << ' ';
    cout << '\n';
    rep(i,n) cout << q[i] << ' ';
    cout << '\n';
}
0