結果

問題 No.2732 Similar Permutations
ユーザー hamo21hamo21
提出日時 2024-04-19 22:06:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,901 bytes
コンパイル時間 5,049 ms
コンパイル使用メモリ 262,540 KB
実行使用メモリ 19,768 KB
最終ジャッジ日時 2024-04-19 22:07:42
合計ジャッジ時間 26,309 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 50 ms
7,936 KB
testcase_03 AC 96 ms
11,776 KB
testcase_04 AC 28 ms
6,144 KB
testcase_05 AC 23 ms
5,632 KB
testcase_06 AC 9 ms
5,376 KB
testcase_07 AC 71 ms
9,728 KB
testcase_08 AC 34 ms
6,784 KB
testcase_09 AC 16 ms
5,376 KB
testcase_10 AC 168 ms
18,284 KB
testcase_11 AC 13 ms
5,376 KB
testcase_12 AC 172 ms
18,616 KB
testcase_13 AC 182 ms
18,496 KB
testcase_14 AC 175 ms
18,616 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 183 ms
19,648 KB
testcase_20 AC 180 ms
19,344 KB
testcase_21 AC 182 ms
19,640 KB
testcase_22 AC 95 ms
12,400 KB
testcase_23 AC 173 ms
19,648 KB
testcase_24 AC 99 ms
12,624 KB
testcase_25 AC 181 ms
19,516 KB
testcase_26 AC 150 ms
17,096 KB
testcase_27 AC 175 ms
19,520 KB
testcase_28 AC 150 ms
16,420 KB
testcase_29 AC 177 ms
19,644 KB
testcase_30 AC 129 ms
15,568 KB
testcase_31 AC 173 ms
19,520 KB
testcase_32 AC 162 ms
18,484 KB
testcase_33 AC 174 ms
19,512 KB
testcase_34 AC 114 ms
13,716 KB
testcase_35 AC 181 ms
19,548 KB
testcase_36 AC 164 ms
18,576 KB
testcase_37 AC 174 ms
19,436 KB
testcase_38 AC 157 ms
17,652 KB
testcase_39 AC 176 ms
19,644 KB
testcase_40 AC 150 ms
17,264 KB
testcase_41 AC 181 ms
19,644 KB
testcase_42 AC 134 ms
16,040 KB
testcase_43 AC 173 ms
19,640 KB
testcase_44 AC 86 ms
11,848 KB
testcase_45 AC 176 ms
19,516 KB
testcase_46 AC 154 ms
18,096 KB
testcase_47 AC 178 ms
19,640 KB
testcase_48 AC 101 ms
13,140 KB
testcase_49 AC 164 ms
19,644 KB
testcase_50 AC 98 ms
13,004 KB
testcase_51 AC 169 ms
19,768 KB
testcase_52 AC 141 ms
17,548 KB
testcase_53 AC 181 ms
18,616 KB
testcase_54 AC 180 ms
18,620 KB
testcase_55 AC 176 ms
18,620 KB
testcase_56 AC 199 ms
18,624 KB
testcase_57 AC 89 ms
11,136 KB
testcase_58 AC 119 ms
14,240 KB
testcase_59 AC 113 ms
13,736 KB
testcase_60 AC 95 ms
11,904 KB
testcase_61 AC 86 ms
11,136 KB
testcase_62 AC 148 ms
16,052 KB
testcase_63 AC 3 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 AC 2 ms
5,376 KB
testcase_70 AC 2 ms
5,376 KB
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 WA -
testcase_75 AC 3 ms
5,376 KB
testcase_76 AC 3 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 2 ms
5,376 KB
testcase_81 AC 2 ms
5,376 KB
testcase_82 AC 3 ms
5,376 KB
testcase_83 WA -
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 3 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 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 3 ms
5,376 KB
testcase_97 AC 3 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<atcoder/all>
using namespace std;
using namespace atcoder;
typedef int64_t ll;
using mint=modint998244353;

typedef long double ld;
const ll MOD=1000000007;
const ll MODA=998244353;
ll vx[4]={0,1,0,-1};
ll vy[4]={1,0,-1,0};
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    a=abs(a);
    b=abs(b);
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    if(gcdmin==0)return gcdmax;
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll pow(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=pow(N,P/2,M);
        return t*t%M;
    }
    else return N*pow(N,P-1,M)%M;
}
ll pow(ll N,ll P){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=pow(N,P/2);
        return t*t;
    }
    else return N*pow(N,P-1);
}

vector<ll> fac;
vector<ll> finv;
vector<ll> inv;
void COMinit(ll N,ll P){
    rep(i,N+1){
        if(i==0){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else if(i==1){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else{
            fac.push_back(fac.at(i-1)*i%P);
            inv.push_back(P-inv.at(P%i)*(P/i)%P);
            finv.push_back(finv.at(i-1)*inv.at(i)%P);
        }
    }
}

ll COM(ll n,ll k,ll P){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac.at(n)*(finv.at(k)*finv.at(n-k)%P)%P;
}


struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2

    UnionFind(ll N) : par(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る:root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時:xの根rxをyの根ryにつける
    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main(){
    ll N;
    cin>>N;
    vector<ll> A(N);
    rep(i,N)cin>>A[i];
    if(N==1){
        cout<<-1<<endl;
        return 0;
    }
    if(N==2){
        if(((A[0]+1)^(A[1]+2))==((A[0]+2)^(A[1]+1))){
            cout<<1<<" "<<2<<endl;
            cout<<2<<" "<<1<<endl;
        }
        else cout<<-1<<endl;
        return 0;
    }
    vector<ll> P1(N);
    vector<ll> P2(N);
    set<ll> S;
    rep(i,N)S.insert(i+1);
    for(ll i=1;i<N;i*=2){
        vector<ll> v;
        rep(j,N){
            if((A[j]&i)==0)v.push_back(j);
        }
        if(v.size()>1){
            if(i==1){
                S.erase(2);
                S.erase(3);
                P1[v[0]]=2;
                P2[v[0]]=3;
                P1[v[1]]=3;
                P2[v[1]]=2;
            }
            else{
                S.erase(i+1);
                S.erase(1);
                P1[v[0]]=i+1;
                P2[v[0]]=1;
                P1[v[1]]=1;
                P2[v[1]]=i+1;
            }
            rep(i,N){
                if(i!=v[0]&&i!=v[1]){
                    P1[i]=(*S.begin());
                    P2[i]=P1[i];
                    S.erase(P1[i]);
                }
            }
            rep(i,N){
                cout<<P1[i]<<" ";
            }
            cout<<endl;
            rep(i,N){
                cout<<P2[i]<<" ";
            }
            cout<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}
0