結果

問題 No.792 真理関数をつくろう
ユーザー t33f
提出日時 2019-02-22 21:28:45
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 855 bytes
コンパイル時間 527 ms
コンパイル使用メモリ 67,544 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-25 07:41:40
合計ジャッジ時間 1,856 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 10 WA * 9 RE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int q[2048][12] = {}, r[12] = {};
    for (int i = 0; i < (1<<n); i++) {
        for (int j = 0; j < n; j++) cin >> q[i][j];
        cin >> r[i];
    }
    cout << "A=";
    if (*max_element(r, r+(1<<n)) == 0) cout << "⊥\n";
    else if (*min_element(r, r+(1<<n)) == 1) cout << "⊤\n";
    else {
        bool fst = true;
        for (int i = 0; i < (1<<n); i++) {
            if (r[i]) {
                if (fst) fst = false;
                else cout << "∨";
                cout << "(";
                for (int j = 0; j < n; j++) {
                    if (j > 0) cout << "∧";
                    if (!q[i][j]) cout << "¬";
                    cout << "P_" << j+1;
                }
                cout << ")";
            }
        }
    }
}
0