結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 2 ms
5,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 3 ms
5,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 WA -
testcase_17 AC 2 ms
5,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 3 ms
5,376 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 4 ms
5,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 4 ms
5,376 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 3 ms
5,376 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 3 ms
5,376 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 WA -
testcase_48 AC 2 ms
5,376 KB
testcase_49 AC 2 ms
5,376 KB
testcase_50 WA -
testcase_51 AC 2 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>

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 << 30) - 1;

  vector< vector< pair< int, int > > > mada(1 << N);
  for(int a = 0; a < (1 << N); a++) {
    for(int b = 0; b < (1 << N); b++) {
      mada[a].emplace_back(b, a ^ b);
    }
  }
  for(int i = 29; i >= 0; i--) {
    queue< int > que;
    for(int j = 0; j < N; j++) {
      if((~B[i] >> i) & 1) {
        que.emplace(j);
      }
    }
    while(not que.empty()) {
      int a = que.front();
      que.pop();
      for(auto&[b, c] : mada[a]) {
        int one = 0;
        one += (B[b] >> i) & 1;
        one += (B[c] >> i) & 1;
        if(one == 1) {
          if((B[b] >> i) & 1) {
            B[b] ^= 1 << i;
            que.emplace(b);
          } else {
            B[c] ^= 1 << i;
            que.emplace(c);
          }
        }
      }
    }
    vector< vector< pair< int, int > > > nxt(1 << N);
    for(int a = 0; a < (1 << N); a++) {
      for(auto&[b, c] : mada[a]) {
        if((~B[a] >> i) & 1 or (~B[b] >> i) & 1 or (~B[c] >> i) & 1) {
          nxt[a].emplace_back(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