結果

問題 No.792 真理関数をつくろう
ユーザー t98slidert98slider
提出日時 2022-07-06 09:00:06
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 811 bytes
コンパイル時間 1,590 ms
コンパイル使用メモリ 169,656 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-23 05:14:23
合計ジャッジ時間 2,769 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<bool> tb(1 << n);
    string ans = "A=";
    for(int i = 0; i < (1 << n); i++){
        int s = 0, v;
        string str = "(";
        for(int j = 0; j < n; j++){
            if(j)str += "∧";
            cin >> v;
            s <<= 1;
            s |= v;
            if(v == 0)str += "¬";
            str += "P_" + to_string(j + 1);
        }
        str += ")";
        cin >> v;
        if(v){
            tb[s] = true;
            if(ans.back() != '=')ans += "∨";
            ans += str;
        }
    }
    int cnt = count(tb.begin(), tb.end(), true);
    if(cnt == (1 << n) || cnt == 0){
        cout << "A=" << (cnt == (1 << n) ? "⊤" : "⊥") << '\n';
        return 0; 
    }
    cout << ans << '\n';
}
0