結果

問題 No.792 真理関数をつくろう
ユーザー tactac
提出日時 2019-07-13 15:22:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 1,279 bytes
コンパイル時間 1,589 ms
コンパイル使用メモリ 170,140 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 18:36:25
合計ジャッジ時間 2,516 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 4 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 4 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 4 ms
6,944 KB
testcase_06 AC 14 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 7 ms
6,944 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 10 ms
6,940 KB
testcase_21 AC 17 ms
6,940 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
int main() {
    int n; cin >> n;
    int a[1 << n][n + 1]; rep(i, (1 << n)) rep(j, n + 1) cin >> a[i][j];
    rep(i, (1 << n)) {
        if (a[i][n] == 0) break;
        if (i == (1 << n) - 1) {
            out("A=⊤");
            return 0;
        }
    }
    rep(i, (1 << n)) {
        if (a[i][n] == 1) break;
        if (i == (1 << n) - 1) {
            out("A=⊥");
            return 0;
        }
    }
    cout << "A=";
    int orflg = 0;
    rep(i, (1 << n)) {
        if (a[i][n] == 0) continue;
        orflg++;
        if (orflg > 1) cout << "∨";
        cout << "(";
        rep(j, n) {
            if (j) cout << "∧";
            if (a[i][j] == 1) {
                cout << "P_" << j + 1;
            } else {
                cout << "¬P_" << j + 1;
            }
        }
        cout << ")";
    }
    cout << endl;
}

0