結果

問題 No.792 真理関数をつくろう
ユーザー face4
提出日時 2019-02-22 21:50:22
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 942 bytes
コンパイル時間 807 ms
コンパイル使用メモリ 78,404 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-25 07:58:39
合計ジャッジ時間 1,629 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<vector<int>> v(1<<n, vector<int>(n+1));
    int cnt = 0;
    for(int i = 0; i < (1<<n); i++){
        for(int j = 0; j < n+1; j++){
            cin >> v[i][j];
        }
        cnt += v[i][n];
    }
    cout << "A=";
    if(cnt == 0){
        cout << "⊥" << endl;
        return 0;
    }else if(cnt == 1<<n){
        cout << "⊤" << endl;
        return 0;
    }
    vector<string> ans;
    for(int i = 0; i < (1<<n); i++){
        if(v[i][n] == 0)    continue;
        string t = "(";
        for(int j = 0; j < n; j++){
            if(j)   t += "∧";
            if(v[i][j] == 0)    t += "¬";
            t += "P_" + to_string(j+1);
        }
        t += ")";
        ans.push_back(t);
    }
    for(int i = 0; i < ans.size(); i++){
        if(i)   cout << "∨";
        cout << ans[i];
    }
    cout << endl;
    return 0;
}
0