結果
| 問題 | No.792 真理関数をつくろう | 
| コンテスト | |
| ユーザー |  dsytk7 | 
| 提出日時 | 2019-02-22 21:36:25 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 12 ms / 2,000 ms | 
| コード長 | 1,184 bytes | 
| コンパイル時間 | 1,447 ms | 
| コンパイル使用メモリ | 169,024 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-25 07:47:49 | 
| 合計ジャッジ時間 | 2,233 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 22 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair<ll, ll>;
using namespace std;
template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}
int q[5000][13];
int r[5000];
int main()
{
    int N;
    cin >> N;
    int one = 0, zero = 0;
    rep(i, pow(2, N)) {
        rep(j, N) cin >> q[i][j];
        cin >> r[i];
        if (r[i]) one++;
        else zero++;
    }
    if (one == pow(2, N)) {
        cout << "A=⊤" << endl;
    }
    else if (zero == pow(2, N)) {
        cout << "A=⊥" << endl;
    }
    else {
        string ans = "";
        rep(i, pow(2, N)) {
            if (r[i]) {
                if (ans.size()) ans += "∨";
                ans += "(";
                //
                rep(j, N) {
                    if (j) ans += "∧";
                    if (q[i][j] == 0) {
                        ans += "¬";
                    }
                    ans += "P_" + to_string(j+1);
                }
                ans += ")";
            }
        }
        cout << "A=" << ans << endl;
    }
}
            
            
            
        