結果
問題 |
No.792 真理関数をつくろう
|
ユーザー |
|
提出日時 | 2022-07-06 09:00:06 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 16 ms / 2,000 ms |
コード長 | 811 bytes |
コンパイル時間 | 2,113 ms |
コンパイル使用メモリ | 170,924 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-21 05:18:37 |
合計ジャッジ時間 | 2,819 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 |
ソースコード
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; vector<bool> tb(1 << n); string ans = "A="; for(int i = 0; i < (1 << n); i++){ int s = 0, v; string str = "("; for(int j = 0; j < n; j++){ if(j)str += "∧"; cin >> v; s <<= 1; s |= v; if(v == 0)str += "¬"; str += "P_" + to_string(j + 1); } str += ")"; cin >> v; if(v){ tb[s] = true; if(ans.back() != '=')ans += "∨"; ans += str; } } int cnt = count(tb.begin(), tb.end(), true); if(cnt == (1 << n) || cnt == 0){ cout << "A=" << (cnt == (1 << n) ? "⊤" : "⊥") << '\n'; return 0; } cout << ans << '\n'; }