結果
問題 |
No.943 取り調べ
|
ユーザー |
|
提出日時 | 2020-05-31 03:49:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 198 ms / 1,206 ms |
コード長 | 496 bytes |
コンパイル時間 | 2,617 ms |
コンパイル使用メモリ | 191,788 KB |
最終ジャッジ日時 | 2025-01-10 19:56:54 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:10:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | int n; scanf("%d",&n); | ~~~~~^~~~~~~~~ main.cpp:13:29: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | int x; scanf("%d",&x); | ~~~~~^~~~~~~~~ main.cpp:17:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 17 | rep(i,n) scanf("%d",&a[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; const int INF=1<<29; int main(){ int n; scanf("%d",&n); int v[18]={}; rep(i,n) rep(j,n) { int x; scanf("%d",&x); if(x==1) v[i]|=1<<j; } int a[18]; rep(i,n) scanf("%d",&a[i]); int ans=INF; rep(S,1<<n){ int x=S; rep(_,n) rep(i,n) if((v[i]&x)==v[i]) x|=1<<i; if(x==(1<<n)-1){ int cost=0; rep(i,n) if(S>>i&1) cost+=a[i]; ans=min(ans,cost); } } printf("%d\n",ans); return 0; }