結果

問題 No.792 真理関数をつくろう
コンテスト
ユーザー Noiri
提出日時 2019-03-02 08:14:39
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 832 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 947 ms
コンパイル使用メモリ 188,432 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-03-08 06:40:23
合計ジャッジ時間 1,681 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 2
other AC * 2 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

int main(){
    int n;
    cin >> n;
    bool isTop = true;
    bool isBottom = true;
    string ans = "A=";
    int loop = n * n;
    if(n == 1) loop = 2;

    for(int i=0; i<loop; i++){
        vector<int> v(n+1);
        for(int j=0; j<=n; j++){
            cin >> v[j];
        }
        if(v[n] == 1){
            isBottom = false;
            ans += "(";
            for(int j=0; j<n; j++){
                if(v[j] == 1) ans += ("P_" + to_string(j+1));
                else if(v[j] == 0) ans += ("¬P_" + to_string(j+1));
                if(j != n-1) ans += "∧";
            }
            ans += ")";
        }
        else isTop = false;
    }
    if(isTop) cout << "A=⊤" << endl;
    else if(isBottom) cout << "A=⊥" << endl;
    else cout << ans << endl;

    return 0;
}
0