結果

問題 No.1652 XOR Inequalities
ユーザー ei1333333ei1333333
提出日時 2021-07-10 03:26:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,469 bytes
コンパイル時間 2,578 ms
コンパイル使用メモリ 202,672 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 03:34:22
合計ジャッジ時間 6,140 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector< int > A(1 << N);
  for(auto &a : A) cin >> a;
  vector< int > B{A};
  for(auto &b : B) if(b == -1) b = (1 << 29) - 1;

  vector< tuple< int, int, int > > mada;
  for(int i = 0; i < (1 << N); i++) {
    for(int j = 0; j < i; j++) {
      int k = (i ^ j);
      if(k < j and j < i) {
        mada.emplace_back(i, j, k);
      }
    }
  }
  // すみません 計算量を何も考えていません
  for(int i = 29; i >= 0; i--) {
    bool update = true;
    while(update) {
      update = false;
      for(auto&[a, b, c] : mada) {
        int one = 0;
        one += (B[a] >> i) & 1;
        one += (B[b] >> i) & 1;
        one += (B[c] >> i) & 1;
        if(one == 1) {
          if((B[a] >> i) & 1) B[a] ^= 1 << i;
          if((B[b] >> i) & 1) B[b] ^= 1 << i;
          if((B[c] >> i) & 1) B[c] ^= 1 << i;
          update = true;
        }
      }
    }
    vector< tuple< int, int, int > > nxt;
    for(auto&[a, b, c]:mada) {
      int one = 0;
      one += (B[a] >> i) & 1;
      one += (B[b] >> i) & 1;
      one += (B[c] >> i) & 1;
      if(one != 3) {
        nxt.emplace_back(a, b, c);
      }
    }
    mada = move(nxt);
  }
  for(int i = 0; i < (1 << N); i++) {
    if(~A[i] and A[i] != B[i]) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  for(int i = 0; i < (1 << N); i++) {
    if(i) cout << " ";
    cout << B[i];
  }
  cout << "\n";
}

0