結果
問題 | No.792 真理関数をつくろう |
ユーザー |
![]() |
提出日時 | 2019-02-22 22:36:19 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 15 ms / 2,000 ms |
コード長 | 666 bytes |
コンパイル時間 | 1,511 ms |
コンパイル使用メモリ | 160,536 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-25 10:06:35 |
合計ジャッジ時間 | 2,538 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 |
ソースコード
#include<bits/stdc++.h> using namespace std; int main(){ int N;cin>>N; int Q[1<<N][N];int R[1<<N]; for(int i=0;i<(1<<N);i++){ for(int j=0;j<N;j++){ cin>>Q[i][j]; }cin>>R[i]; }for(int k=1;k<(1<<N);k++){ if(R[k-1]!=R[k]){ break; }if(k==(1<<N)-1){ if(R[k]==0){ cout<<"A=⊥"<<endl; }else{ cout<<"A=⊤"<<endl; }return 0; } }int count=0; cout<<"A="; for(int i=0;i<(1<<N);i++){ if(R[i]==1){ if(count!=0){ cout<<"∨"; }count++; cout<<"("; for(int j=0;j<N;j++){ if(Q[i][j]==1){ cout<<"P_"<<j+1; }else{ cout<<"¬P_"<<j+1; }if(j!=N-1){ cout<<"∧"; } }cout<<")"; } }cout<<endl; }