結果

問題 No.2732 Similar Permutations
ユーザー ttkkggwwttkkggww
提出日時 2024-05-02 09:47:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,742 bytes
コンパイル時間 5,193 ms
コンパイル使用メモリ 268,704 KB
実行使用メモリ 16,312 KB
最終ジャッジ日時 2024-05-02 09:47:29
合計ジャッジ時間 27,385 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 34 ms
7,168 KB
testcase_03 AC 64 ms
10,496 KB
testcase_04 AC 19 ms
5,760 KB
testcase_05 AC 15 ms
5,376 KB
testcase_06 AC 8 ms
5,376 KB
testcase_07 AC 43 ms
8,704 KB
testcase_08 AC 23 ms
6,016 KB
testcase_09 AC 11 ms
5,376 KB
testcase_10 AC 113 ms
15,616 KB
testcase_11 AC 9 ms
5,376 KB
testcase_12 AC 113 ms
16,060 KB
testcase_13 AC 111 ms
16,056 KB
testcase_14 AC 105 ms
16,044 KB
testcase_15 AC 106 ms
15,996 KB
testcase_16 AC 78 ms
12,580 KB
testcase_17 AC 79 ms
12,316 KB
testcase_18 AC 103 ms
15,020 KB
testcase_19 AC 123 ms
16,060 KB
testcase_20 AC 139 ms
15,904 KB
testcase_21 AC 110 ms
16,056 KB
testcase_22 AC 60 ms
10,496 KB
testcase_23 AC 107 ms
16,188 KB
testcase_24 AC 65 ms
10,648 KB
testcase_25 AC 109 ms
16,188 KB
testcase_26 AC 89 ms
14,148 KB
testcase_27 AC 112 ms
16,180 KB
testcase_28 AC 83 ms
13,588 KB
testcase_29 AC 104 ms
16,312 KB
testcase_30 AC 76 ms
12,912 KB
testcase_31 AC 106 ms
16,184 KB
testcase_32 AC 101 ms
15,312 KB
testcase_33 AC 109 ms
16,180 KB
testcase_34 AC 69 ms
11,584 KB
testcase_35 AC 109 ms
16,056 KB
testcase_36 AC 99 ms
15,164 KB
testcase_37 AC 120 ms
16,184 KB
testcase_38 AC 93 ms
14,752 KB
testcase_39 AC 106 ms
16,052 KB
testcase_40 AC 91 ms
14,192 KB
testcase_41 AC 107 ms
16,052 KB
testcase_42 AC 82 ms
13,176 KB
testcase_43 AC 110 ms
16,312 KB
testcase_44 AC 55 ms
9,984 KB
testcase_45 AC 106 ms
16,188 KB
testcase_46 AC 96 ms
15,028 KB
testcase_47 AC 108 ms
16,184 KB
testcase_48 AC 62 ms
10,976 KB
testcase_49 AC 104 ms
16,312 KB
testcase_50 AC 63 ms
10,880 KB
testcase_51 AC 105 ms
16,180 KB
testcase_52 AC 87 ms
14,440 KB
testcase_53 AC 109 ms
16,000 KB
testcase_54 AC 108 ms
16,068 KB
testcase_55 AC 107 ms
15,944 KB
testcase_56 AC 107 ms
15,948 KB
testcase_57 AC 55 ms
9,984 KB
testcase_58 AC 74 ms
12,396 KB
testcase_59 AC 70 ms
11,904 KB
testcase_60 AC 61 ms
10,368 KB
testcase_61 AC 52 ms
9,856 KB
testcase_62 AC 88 ms
13,784 KB
testcase_63 AC 2 ms
5,376 KB
testcase_64 AC 2 ms
5,376 KB
testcase_65 AC 2 ms
5,376 KB
testcase_66 AC 2 ms
5,376 KB
testcase_67 AC 2 ms
5,376 KB
testcase_68 AC 2 ms
5,376 KB
testcase_69 WA -
testcase_70 WA -
testcase_71 AC 3 ms
5,376 KB
testcase_72 WA -
testcase_73 WA -
testcase_74 AC 3 ms
5,376 KB
testcase_75 AC 2 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 2 ms
5,376 KB
testcase_80 AC 1 ms
5,376 KB
testcase_81 AC 2 ms
5,376 KB
testcase_82 AC 2 ms
5,376 KB
testcase_83 AC 2 ms
5,376 KB
testcase_84 AC 1 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 2 ms
5,376 KB
testcase_90 AC 2 ms
5,376 KB
testcase_91 AC 2 ms
5,376 KB
testcase_92 AC 1 ms
5,376 KB
testcase_93 AC 2 ms
5,376 KB
testcase_94 AC 1 ms
5,376 KB
testcase_95 AC 2 ms
5,376 KB
testcase_96 AC 1 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 2 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[4];
    for(int i = 0;i<N;i++){
        bin[A[i]%4].push_back(i);
    }
    if(bin[0].size() > 1){
        int l = bin[0][0];
        int r = bin[0][1];
        a[l] = 1;
        a[r] = 3;
        b[r] = 1;
        b[l] = 3;
        st.erase(1);
        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 if(bin[2].size() > 1){
        int l = bin[2][0];
        int r = bin[2][1];
        a[l] = 2;
        a[r] = 3;
        b[r] = 2;
        b[l] = 3;
        st.erase(2);
        st.erase(3);
    }else if(bin[3].size() > 1){
        int l = bin[3][0];
        int r = bin[3][1];
        a[l] = 1;
        a[r] = 3;
        b[r] = 1;
        b[l] = 3;
        st.erase(1);
        st.erase(3);
    }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