結果

問題 No.792 真理関数をつくろう
ユーザー t33f
提出日時 2019-02-22 22:11:15
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 873 bytes
コンパイル時間 513 ms
コンパイル使用メモリ 68,120 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-25 08:48:15
合計ジャッジ時間 1,399 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 2
other AC * 11 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int q[5000][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 << ")";
            }
        }
    }
    cout << endl;
}
0