結果

問題 No.792 真理関数をつくろう
ユーザー しとおしとお
提出日時 2019-02-22 22:24:01
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 965 bytes
コンパイル時間 709 ms
コンパイル使用メモリ 72,656 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-04 03:06:51
合計ジャッジ時間 1,436 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int main(){
    int n;
    cin >> n;
    int pn=int(pow(2, n));
    vector<vector<int>>t(pn, vector<int>(n+1));
    for(int i=0; i<pn; i++){
        for(int j=0; j<n+1; j++){
            cin >> t[i][j];
        }
    }
    vector<string>ret;
    for(int i=0; i<pn; i++){
        if(t[i][n]){
            string str="";
            str.push_back('(');
            for(int j=0; j<n; j++){
                if(!t[i][j])str+="¬";
                str+="P_"+to_string(j+1);
                if(j!=n-1)str+="∧";
            }
            str.push_back(')');
            ret.push_back(str);
        }
    }
    cout << "A=";
    if(ret.size()==0)cout << "⊥";
    else if(ret.size()==pn)cout << "⊤";
    else{
        for(int i=0; i<ret.size(); i++){
            cout << ret[i];
            if(i!=ret.size()-1)cout << "∨";
        }
    }
    cout << endl;
    return 0;
}
0