結果

問題 No.2732 Similar Permutations
ユーザー ttkkggwwttkkggww
提出日時 2024-05-02 10:12:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,340 bytes
コンパイル時間 4,849 ms
コンパイル使用メモリ 268,324 KB
実行使用メモリ 16,312 KB
最終ジャッジ日時 2024-05-02 10:12:53
合計ジャッジ時間 22,173 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 32 ms
7,296 KB
testcase_03 AC 56 ms
10,368 KB
testcase_04 AC 16 ms
5,760 KB
testcase_05 AC 14 ms
5,376 KB
testcase_06 AC 9 ms
5,376 KB
testcase_07 AC 42 ms
8,704 KB
testcase_08 AC 21 ms
6,144 KB
testcase_09 AC 12 ms
5,376 KB
testcase_10 AC 97 ms
15,516 KB
testcase_11 AC 8 ms
5,376 KB
testcase_12 AC 101 ms
16,056 KB
testcase_13 AC 108 ms
16,052 KB
testcase_14 AC 102 ms
16,180 KB
testcase_15 AC 105 ms
16,184 KB
testcase_16 AC 70 ms
12,748 KB
testcase_17 AC 68 ms
12,692 KB
testcase_18 AC 91 ms
15,240 KB
testcase_19 AC 103 ms
16,060 KB
testcase_20 AC 102 ms
16,028 KB
testcase_21 AC 124 ms
16,092 KB
testcase_22 AC 61 ms
10,580 KB
testcase_23 AC 103 ms
16,184 KB
testcase_24 AC 56 ms
10,752 KB
testcase_25 AC 119 ms
16,184 KB
testcase_26 AC 99 ms
14,152 KB
testcase_27 AC 107 ms
16,056 KB
testcase_28 AC 79 ms
13,460 KB
testcase_29 AC 114 ms
16,188 KB
testcase_30 AC 69 ms
12,780 KB
testcase_31 AC 111 ms
16,184 KB
testcase_32 AC 103 ms
15,316 KB
testcase_33 AC 102 ms
16,188 KB
testcase_34 AC 73 ms
11,712 KB
testcase_35 AC 101 ms
16,056 KB
testcase_36 AC 94 ms
15,416 KB
testcase_37 AC 99 ms
16,060 KB
testcase_38 AC 85 ms
14,496 KB
testcase_39 AC 101 ms
16,312 KB
testcase_40 AC 82 ms
14,196 KB
testcase_41 AC 100 ms
16,184 KB
testcase_42 AC 90 ms
13,176 KB
testcase_43 AC 120 ms
16,184 KB
testcase_44 AC 52 ms
10,028 KB
testcase_45 AC 112 ms
16,052 KB
testcase_46 AC 93 ms
15,032 KB
testcase_47 AC 106 ms
16,056 KB
testcase_48 AC 59 ms
11,008 KB
testcase_49 AC 110 ms
16,052 KB
testcase_50 AC 61 ms
11,008 KB
testcase_51 AC 107 ms
16,052 KB
testcase_52 AC 82 ms
14,308 KB
testcase_53 AC 111 ms
16,056 KB
testcase_54 AC 100 ms
16,144 KB
testcase_55 AC 100 ms
16,016 KB
testcase_56 AC 115 ms
15,996 KB
testcase_57 AC 50 ms
9,984 KB
testcase_58 AC 68 ms
12,260 KB
testcase_59 AC 67 ms
11,956 KB
testcase_60 AC 54 ms
10,496 KB
testcase_61 AC 50 ms
9,728 KB
testcase_62 AC 93 ms
13,848 KB
testcase_63 AC 3 ms
5,376 KB
testcase_64 AC 3 ms
5,376 KB
testcase_65 AC 2 ms
5,376 KB
testcase_66 AC 2 ms
5,376 KB
testcase_67 WA -
testcase_68 AC 2 ms
5,376 KB
testcase_69 AC 3 ms
5,376 KB
testcase_70 AC 2 ms
5,376 KB
testcase_71 AC 2 ms
5,376 KB
testcase_72 AC 2 ms
5,376 KB
testcase_73 AC 2 ms
5,376 KB
testcase_74 AC 3 ms
5,376 KB
testcase_75 AC 3 ms
5,376 KB
testcase_76 AC 2 ms
5,376 KB
testcase_77 AC 2 ms
5,376 KB
testcase_78 AC 2 ms
5,376 KB
testcase_79 AC 3 ms
5,376 KB
testcase_80 AC 2 ms
5,376 KB
testcase_81 AC 2 ms
5,376 KB
testcase_82 AC 2 ms
5,376 KB
testcase_83 AC 3 ms
5,376 KB
testcase_84 AC 3 ms
5,376 KB
testcase_85 AC 2 ms
5,376 KB
testcase_86 AC 2 ms
5,376 KB
testcase_87 AC 2 ms
5,376 KB
testcase_88 AC 2 ms
5,376 KB
testcase_89 AC 3 ms
5,376 KB
testcase_90 AC 3 ms
5,376 KB
testcase_91 AC 3 ms
5,376 KB
testcase_92 AC 2 ms
5,376 KB
testcase_93 AC 3 ms
5,376 KB
testcase_94 AC 2 ms
5,376 KB
testcase_95 AC 2 ms
5,376 KB
testcase_96 AC 2 ms
5,376 KB
testcase_97 AC 2 ms
5,376 KB
testcase_98 AC 2 ms
5,376 KB
testcase_99 AC 2 ms
5,376 KB
testcase_100 AC 3 ms
5,376 KB
testcase_101 AC 2 ms
5,376 KB
testcase_102 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <vector>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
int N;
vector<int> A;

void solve(){
    set<int> st;
    for(int i = 0;i<N;i++){
        st.insert(i+1);
    }
    vector<int> a(N),b(N);
    vector<int> bin[2];
    for(int i = 0;i<N;i++){
        bin[A[i]%2].push_back(i);
    }
    if(bin[0].size() > 1){
        int l = bin[0][0];
        int r = bin[0][1];
        a[l] = 2;
        a[r] = 3;
        b[r] = 2;
        b[l] = 3;
        st.erase(2);
        st.erase(3);
    }else if(bin[1].size() >1){
        int l = bin[1][0];
        int r = bin[1][1];
        a[l] = 1;
        a[r] = 2;
        b[r] = 1;
        b[l] = 2;
        st.erase(1);
        st.erase(2);
    }else{
        cout<<-1<<endl;
        return;
    }
    for(int i = 0;i<N;i++){
        if(a[i] != 0){
            continue;
        }
        a[i] = *st.begin();
        b[i] = *st.begin();
        st.erase(st.begin());
    }
    for(int i = 0;i<N;i++){
        cout << a[i] << " ";
    }
    cout << endl;
    for(int i = 0;i<N;i++){
        cout << b[i] << " ";
    }
    cout << endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    A = vector<int>(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    solve();
}
0