結果
問題 | No.792 真理関数をつくろう |
ユーザー |
![]() |
提出日時 | 2019-02-22 22:00:42 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 20 ms / 2,000 ms |
コード長 | 1,732 bytes |
コンパイル時間 | 1,031 ms |
コンパイル使用メモリ | 108,212 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-25 08:22:59 |
合計ジャッジ時間 | 1,892 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 |
ソースコード
#include<iostream>#include<vector>#include<algorithm>#include<functional>#include<queue>#include<stack>#include<set>#include<map>#include<unordered_map>#include<climits>#include<cstdlib>#include<cmath>#include<string>#include<iomanip>#include<bitset>#include<sstream>using namespace std;#define ll long long intll const MOD = 1000000007;ll const INF = (long long int)1 << 61;int main(){cin.tie(0);ios::sync_with_stdio(false);ll n;cin >> n;ll t = 1 << n;vector<vector<bool>> q(n,vector<bool>(t));vector<bool> r(t);for(int i = 0; i < t; i++){int tmp;for(int j = 0; j < n; j++){cin >> tmp;q[j][i] = (bool)tmp;}cin >> tmp;r[i] = (bool)tmp;}bool allt = true;bool allf = true;int c = 0;for(int i = 0; i < t; i++){if(r[i])c++;allt = allt && r[i];allf = allf && (!r[i]);}if(allt){cout << "A=⊤";return 0;}if(allf){cout << "A=⊥";return 0;}cout << "A=";bool flag = false;for(int i = 0; i < t; i++){if(r[i]){if(flag){cout << "∨";}cout << "(";for(int j = 0; j < n; j++){if(j > 0){cout << "∧";}if(!q[j][i]){cout << "¬";}cout << "P_";std::stringstream s;s << j+1;cout << s.str();}cout << ")";flag = true;}}cout <<endl;return 0;}