結果

問題 No.792 真理関数をつくろう
ユーザー chocorusk
提出日時 2019-02-22 22:05:24
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 1,240 bytes
コンパイル時間 764 ms
コンパイル使用メモリ 98,380 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-25 08:33:31
合計ジャッジ時間 1,634 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
string num[12]={"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"};
int main()
{
	int n; cin>>n;
    int q[1<<12][12], r[1<<12];
    bool all=1, nall=1;
    int m=0;
    for(int i=0; i<(1<<n); i++){
        for(int j=0; j<n; j++){
            cin>>q[i][j];
        }
        cin>>r[i];
        if(r[i]) nall=0, m=i;
        else all=0;
    }
    if(all){
        cout<<"A=⊤"<<endl;
        return 0;
    }else if(nall){
        cout<<"A=⊥"<<endl;
        return 0;
    }
    string ans="A=";
    for(int i=0; i<(1<<n); i++){
        if(r[i]==0) continue;
        ans+='(';
        for(int j=0; j<n; j++){
            if(q[i][j]==0) ans+="¬";
            ans+="P_";
            ans+=num[j];
            if(j<n-1) ans+="∧";
            else ans+=')';
        }
        if(i<m) ans+="∨";
    }
    cout<<ans<<endl;
    return 0;
}
0