結果
| 問題 | No.3158 Collect Stamps |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-07-15 22:23:53 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,386 bytes |
| 記録 | |
| コンパイル時間 | 1,196 ms |
| コンパイル使用メモリ | 226,652 KB |
| 最終ジャッジ日時 | 2026-07-13 06:42:42 |
| 合計ジャッジ時間 | 1,900 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / 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 = long long int]':
main.cpp:37:22: required from here
37 | 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>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll inf_ll = 9223372036854775807;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using mint = atcoder::modint998244353;
using mint1 = atcoder::modint1000000007;
using Pa = std::pair<ll, ll>;
int Yes(bool x){
if(x) cout << "Yes";
else cout << "No";
cout << endl;
return 0;
}
int main(){
ll N, M, K;
cin >> N >> M >> K;
vector<ll> A(K);
rep(i, K){
cin >> A[i];
A[i]--;
}
vector<vector<ll>> T(N, vector<ll>(N));
rep(i, N){
rep(j, N){
cin >> T[i][j];
}
}
ll ans = inf_ll;
rep(i, (1<<N)){
if(__popcount(i) != M) continue;
vector<ll> B;
rep(j, N){
if((i >> j) & 1) B.push_back(j);
}
do{
ll x = 0;
rep(j, M-1){
x += T[B[j]][B[j+1]];
}
ll y = inf_ll;
rep(j, K){
chmin(y, T[B[M-1]][A[j]]);
}
x += y;
chmin(ans, x);
}while(next_permutation(B.begin(), B.end()));
}
cout << ans;
}