結果
| 問題 | No.3312 Fire Engine |
| コンテスト | |
| ユーザー |
tau1235
|
| 提出日時 | 2025-10-24 22:28:44 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 727 bytes |
| 記録 | |
| コンパイル時間 | 1,985 ms |
| コンパイル使用メモリ | 331,852 KB |
| 最終ジャッジ日時 | 2026-07-15 23:28:51 |
| 合計ジャッジ時間 | 2,677 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_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:24:27: required from here
24 | int p=n+1-__popcount(ni);
| ~~~~~~~~~~^~~~
/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(){
using ll=long long;
ll inf=1e18;
int n;
cin>>n;
vector<vector<int>> d(n,vector<int>(n));
for (int i=0;i<n;i++) for (int j=0;j<n;j++) cin>>d[i][j];
vector<vector<ll>> dp(1<<n,vector<ll>(n,inf));
priority_queue<tuple<ll,int,int>> q;
q.push({0,1,0});
while (!q.empty()){
auto [dist,i,v]=q.top();
q.pop();
if (dp[i][v]!=inf) continue;
dist*=-1;
dp[i][v]=dist;
for (int u=0;u<n;u++){
int ni=i|(1<<u);
if (ni==i) continue;
ll nd=dist;
int p=n+1-__popcount(ni);
nd+=p*d[v][u];
q.push({-nd,ni,u});
}
}
ll ans=inf;
for (int i=0;i<n;i++) ans=min(ans,dp[(1<<n)-1][i]);
cout<<ans<<endl;
}
tau1235