結果
問題 |
No.792 真理関数をつくろう
|
ユーザー |
|
提出日時 | 2020-04-13 03:26:45 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 11 ms / 2,000 ms |
コード長 | 624 bytes |
コンパイル時間 | 2,890 ms |
コンパイル使用メモリ | 195,288 KB |
最終ジャッジ日時 | 2025-01-09 17:51:55 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:8:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 8 | int n; scanf("%d",&n); | ~~~~~^~~~~~~~~ main.cpp:11:31: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | rep(j,n) scanf("%d",&q[i][j]); | ~~~~~^~~~~~~~~~~~~~~ main.cpp:12:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%d",&r[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; int main(){ int n; scanf("%d",&n); int q[1<<12][12],r[1<<12]; rep(i,1<<n){ rep(j,n) scanf("%d",&q[i][j]); scanf("%d",&r[i]); } string ans="A="; if(count(r,r+(1<<n),0)==0){ ans+="⊤"; } else if(count(r,r+(1<<n),1)==0){ ans+="⊥"; } else{ bool first=true; rep(i,1<<n) if(r[i]==1) { if(!first) ans+="∨"; first=false; string tmp="("; rep(j,n){ if(j>0) tmp+="∧"; if(q[i][j]==0) tmp+="¬"; tmp+="P_"+to_string(j+1); } tmp+=")"; ans+=tmp; } } cout<<ans<<'\n'; return 0; }