結果
問題 |
No.792 真理関数をつくろう
|
ユーザー |
![]() |
提出日時 | 2024-10-30 00:57:47 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 13 ms / 2,000 ms |
コード長 | 1,139 bytes |
コンパイル時間 | 3,375 ms |
コンパイル使用メモリ | 256,340 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-30 00:57:52 |
合計ジャッジ時間 | 4,856 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { int n; cin >> n; vector<pair<vector<bool>, bool>> a(1 << n); rep(i, 1 << n) { a[i].first.resize(n); rep(j, n) { int x; cin >> x; a[i].first[j] = x; } int x; cin >> x; a[i].second = x; } Debug(a); { bool ok = true; rep(i, 1 << n) ok &= a[i].second; if (ok) { cout << "A=⊤" << endl; return 0; } } { bool ok = true; rep(i, 1 << n) ok &= !a[i].second; if (ok) { cout << "A=⊥" << endl; return 0; } } string ans = "A="; bool flg = false; rep(i, 1 << n) { if (a[i].second) { Debug(i); if (flg) ans += "∨"; flg = true; ans += "("; rep(j, n) { if (!a[i].first[j]) ans += "¬"; ans += "P_" + to_string(j + 1); if (j < n - 1) ans += "∧"; } ans += ")"; } } cout << ans << endl; return 0; }