結果

問題 No.1652 XOR Inequalities
ユーザー noya2noya2
提出日時 2021-08-21 00:10:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,351 bytes
コンパイル時間 4,294 ms
コンパイル使用メモリ 258,408 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-22 09:34:31
合計ジャッジ時間 11,183 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 WA -
testcase_07 AC 2 ms
5,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 2 ms
5,376 KB
testcase_13 WA -
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 5 ms
5,376 KB
testcase_16 WA -
testcase_17 AC 4 ms
5,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 5 ms
5,376 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 5 ms
5,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 6 ms
5,376 KB
testcase_31 WA -
testcase_32 AC 4 ms
5,376 KB
testcase_33 AC 5 ms
5,376 KB
testcase_34 AC 4 ms
5,376 KB
testcase_35 AC 5 ms
5,376 KB
testcase_36 AC 4 ms
5,376 KB
testcase_37 AC 4 ms
5,376 KB
testcase_38 AC 5 ms
5,376 KB
testcase_39 AC 4 ms
5,376 KB
testcase_40 AC 5 ms
5,376 KB
testcase_41 AC 4 ms
5,376 KB
testcase_42 AC 5 ms
5,376 KB
testcase_43 AC 5 ms
5,376 KB
testcase_44 AC 5 ms
5,376 KB
testcase_45 AC 5 ms
5,376 KB
testcase_46 AC 3 ms
5,376 KB
testcase_47 AC 5 ms
5,376 KB
testcase_48 AC 2 ms
5,376 KB
testcase_49 AC 1 ms
5,376 KB
testcase_50 AC 2 ms
5,376 KB
testcase_51 AC 1 ms
5,376 KB
testcase_52 AC 2 ms
5,376 KB
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define repb(i,n) for (int i = int(n)-1; i >= 0; --i)
using namespace std;
using namespace atcoder;
using P = pair<int, int>;
template<typename T>void priv(vector<T> &v){if(v.size()==0){cout<<endl;}else{rep(i,v.size()-1)cout<<v[i]<<" ";cout<<v[v.size()-1]<<endl;}}

int main(){
    int n; cin >> n;
    n = 1 << n;
    vector<int> ar(n);
    rep(i,n) cin >> ar[i];
    vector<vector<int>> v(n,vector<int>(30,-1));
    rep(i,n) if (ar[i] != -1) rep(j,30) v[i][j] = ar[i] >> j & 1;
    rep(d,30){
        queue<P> que;
        rep(i,n) rep(j,n){
            if (v[i][d] == 0 && v[j][d] == 0) que.push(P(i,j));
        }
        while (!que.empty()){
            P p = que.front(); que.pop();
            int a = p.first;
            int b = p.second;
            if (v[a^b][d] == -1){
                v[a^b][d] = 0;
                rep(i,n) if (v[i][d] == 0) que.push(P(a^b,i));
            }
        }
        rep(i,n) if (v[i][d] == -1) v[i][d] = 1;
    }
    vector<int> ans(n,0);
    rep(i,n){
        repb(j,30) ans[i] += v[i][j], ans[i] *= 2;
        ans[i] /= 2;
    }
    bool t = true;
    rep(i,n) rep(j,n){
        if (ans[i^j] < (ans[i] ^ ans[j])) t = false;
    }
    if (t) cout << "Yes" << endl, priv(ans);
    else cout << "No" << endl;
}
0