結果
| 問題 | No.3158 Collect Stamps |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-05-23 21:08:49 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 859 bytes |
| 記録 | |
| コンパイル時間 | 1,037 ms |
| コンパイル使用メモリ | 201,452 KB |
| 最終ジャッジ日時 | 2026-07-11 00:36:47 |
| 合計ジャッジ時間 | 1,654 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_0 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bits/stl_algobase.h:76,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/algorithm:62,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:53,
from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bit: In instantiation of 'constexpr int std::__popcount(_Tp) [with _Tp = int]':
main.cpp:25:22: required from here
25 | if(__popcount(i) < M) continue;
| ~~~~~~~~~~^~~
/home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bit:308:34: error: argument 1 in call to function '__builtin_popcountg' has signed type
308 | return __builtin_popcountg(__x);
| ^~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N,M,K; cin >> N >> M >> K;
vector<int> A(K);
for(auto &a : A) cin >> a,a--;
vector<vector<int>> dist(N,vector<int>(N));
for(auto &h : dist) for(auto &w : h) cin >> w;
int n2 = 1<<N;
vector<vector<int>> dp(n2,vector<int>(N,1e9));
for(int i=0; i<N; i++) dp.at(1<<i).at(i) = 0;
for(int i=1; i<n2; i++){
for(int k=0; k<N; k++) if(i&(1<<k)) for(int l=0; l<N; l++) if(k != l && (i&(1<<l))){
dp.at(i).at(l) = min(dp.at(i).at(l),dp.at(i-(1<<l)).at(k)+dist.at(k).at(l));
}
}
int answer = 1e9;
for(int i=0; i<n2; i++){
if(__popcount(i) < M) continue;
for(auto pos : A) answer = min(answer,dp.at(i).at(pos));
}
cout << answer << endl;
}