結果
| 問題 |
No.943 取り調べ
|
| コンテスト | |
| ユーザー |
ngtkana
|
| 提出日時 | 2020-03-28 13:04:19 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 1,206 ms |
| コード長 | 778 bytes |
| コンパイル時間 | 2,233 ms |
| コンパイル使用メモリ | 196,968 KB |
| 最終ジャッジ日時 | 2025-01-09 10:41:14 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 |
ソースコード
#include<bits/stdc++.h>
using lint=long long;
using real=long double;
void cmn(lint&x,lint y){if(x>y)x=y;}
int main(){
std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
lint inf=std::numeric_limits<lint>::max();
lint n,N;std::cin>>n;N=1ll<<n;
std::vector<lint>g(n),a(n),dp(N,inf);
for(lint i=0;i<n;i++){
for(lint j=0;j<n;j++){
lint x;std::cin>>x;
if(x&1)g.at(i)|=1ll<<j;
}
}
for(lint&x:a)std::cin>>x;
dp.at(0)=0;
for(lint bs=0;bs<N;bs++){
for(lint i=0;i<n;i++){
if(bs>>i&1)continue;
cmn(dp.at(bs|1ll<<i),dp.at(bs)+(g.at(i)&~bs?a.at(i):0ll));
}
}
std::cout<<dp.at(N-1)<<'\n';
}
ngtkana