結果
問題 | No.792 真理関数をつくろう |
ユーザー |
|
提出日時 | 2022-07-06 08:59:01 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 803 bytes |
コンパイル時間 | 1,520 ms |
コンパイル使用メモリ | 171,540 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-21 05:17:07 |
合計ジャッジ時間 | 2,579 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 3 |
other | WA * 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 == n ? "⊤" : "⊥") << '\n'; return 0; } cout << ans << '\n'; }