結果

問題 No.792 真理関数をつくろう
ユーザー rtia_iidxrtia_iidx
提出日時 2019-02-22 22:00:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,707 bytes
コンパイル時間 1,231 ms
コンパイル使用メモリ 106,820 KB
実行使用メモリ 5,276 KB
最終ジャッジ日時 2023-08-16 18:42:39
合計ジャッジ時間 2,251 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<sstream>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    cin >> n;

    ll t = 1 << n;

    vector<vector<bool>> q(n,vector<bool>(t));
    vector<bool> r(t);
    for(int i = 0; i < t; i++){
        int tmp;
        for(int j = 0; j < n; j++){
            cin >> tmp;
            q[j][i] = (bool)tmp;
        }
        cin >> tmp;
        r[i] = (bool)tmp;
    }

    bool allt = true;
    bool allf = true;
    int c = 0;

    for(int i = 0; i < t; i++){
        if(r[i])c++;
        allt = allt && r[i];
        allf = allf && (!r[i]);
    }

    if(allt){
        cout << "A=⊤";
        return 0;
    }
    if(allf){
        cout << "A=⊥";
        return 0;
    }

    cout << "A=";
    
    bool flag = false;

    for(int i = 0; i < t; i++){
        if(r[i]){
            if(flag){
                cout << "∨";
            }
                cout << "(";
            for(int j = 0; j < n; j++){
                if(j > 0){
                    cout << "∧";
                }
                if(!q[j][i]){
                    cout << "¬";
                }
                cout << "P_";
                std::stringstream s;
                s << j+1;
                cout << s.str();
            }
            flag = true;
        }
    }

    cout <<endl;
    
    return 0;
}
0