結果
| 問題 | No.792 真理関数をつくろう | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2022-01-20 20:23:45 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,018 bytes | 
| コンパイル時間 | 2,126 ms | 
| コンパイル使用メモリ | 170,184 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-24 04:42:50 | 
| 合計ジャッジ時間 | 2,672 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 4 | 
| other | WA * 22 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    int lim = 1 << n;
    vector<string> q(lim);
    string r[lim];
    bool top = true;
    bool bottom = true;
    for(int i=0;i<lim;i++) {
        char ch;
        for(int j=0;j<n;j++) {
            cin >> ch;
            q[i] += ch;
        }
        cin >> r[i];
        if(r[i] == "0") top = false;
        else bottom = false;
    }
    if(top) {
        cout << "⊤" << '\n';
        return 0;
    }
    if(bottom) {
        cout << "⊥" << '\n';
        return 0;
    }
    string out = "A=";
    for(int i=0;i<lim;i++) {
        if(r[i] == "1") {
            out += '(';
            for(int j=0;j<n;j++) {
                char add = '0' + j + 1;
                if(q[i][j] == '0') out += "¬"; 
                out += ("P_" + add);
                if(j != n-1) out += "∧";
            }
            out += ')';
            out += "∨";
        }
    }
    out.pop_back();
    cout << out << '\n';
    return 0;
}
            
            
            
        