結果

問題 No.792 真理関数をつくろう
ユーザー ei1333333
提出日時 2019-02-22 21:26:53
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 859 bytes
コンパイル時間 1,641 ms
コンパイル使用メモリ 192,804 KB
最終ジャッジ日時 2025-01-06 21:35:42
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using int64 = long long;

int main() {
  int N, Q[1 << 12][12], K[1 << 12];

  cin >> N;
  cout << "A=";
  bool ok = false;
  bool all = false;
  for(int i = 0; i < 1 << N; i++) {
    int bit[12];
    for(int j = 0; j < N; j++) {
      cin >> Q[i][j];
    }
    cin >> K[i];
    if(K[i] == 0) all = true;
  }
  if(!all) {
    cout << "⊤" << endl;
    return 0;
  }
  for(int i = 0; i < 1 << N; i++) {
    if(K[i] == 1) {
      if(ok) cout << "∨";
      ok = true;
      cout << "(";
      for(int j = 0; j < N; j++) {
        if(j > 0) {
          cout << "∧";
        }
        if(Q[i][j] == 0) {
          cout << "¬P_" << j + 1;
        } else {
          cout << "P_" << j + 1;
        }
      }
      cout << ")";
    }
  }
  if(!ok) {
    cout << "⊥" << endl;
  } else {
    cout << endl;
  }


}
0