結果
| 問題 |
No.792 真理関数をつくろう
|
| コンテスト | |
| ユーザー |
momoyuu
|
| 提出日時 | 2024-10-01 22:44:40 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 2,000 ms |
| コード長 | 1,036 bytes |
| コンパイル時間 | 1,172 ms |
| コンパイル使用メモリ | 98,392 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-01 22:44:44 |
| 合計ジャッジ時間 | 2,202 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 22 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
// // char a = '∧';
// char b = '∨';
// char c = '¬';
// char d = '⊥';
// char e = '⊤';
int n;
cin>>n;
int cnt = 0;
vector<int> r(1<<n);
vector<vector<int>> q(1<<n,vector<int>(n,0));
for(int i = 0;i<1<<n;i++){
for(int j = 0;j<n;j++) cin>>q[i][j];
cin>>r[i];
if(r[i]==1) cnt++;
}
if(cnt==(1<<n)){
cout<<"A=⊤"<<endl;
return 0;
}else if(cnt==0){
cout<<"A=⊥";
return 0;
}
cout<<"A=";
bool fn = false;
for(int i = 0;i<1<<n;i++){
if(r[i]==0) continue;
if(fn) cout<<"∨";
cout<<"(";
fn = true;
for(int j = 0;j<n;j++){
if(j) cout<<"∧";
if(q[i][j]==0) cout<<"¬"<<"P_"<<j+1;
else cout<<"P_"<<j+1;
}
cout<<")";
}
cout<<endl;
}
momoyuu