結果
問題 | No.792 真理関数をつくろう |
ユーザー |
|
提出日時 | 2019-03-02 08:23:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 13 ms / 2,000 ms |
コード長 | 906 bytes |
コンパイル時間 | 1,792 ms |
コンパイル使用メモリ | 172,000 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-23 12:16:35 |
合計ジャッジ時間 | 2,710 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main(){int n;cin >> n;bool isTop = true;bool isBottom = true;string ans = "A=";int loop = pow(2, n);bool existPre = false;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;if(existPre) ans += "∨";existPre = true;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;}