結果

問題 No.1690 Power Grid
ユーザー たたき@競プロたたき@競プロ
提出日時 2023-08-27 13:22:12
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 926 bytes
コンパイル時間 5,034 ms
コンパイル使用メモリ 309,980 KB
実行使用メモリ 42,396 KB
最終ジャッジ日時 2023-08-27 13:22:27
合計ジャッジ時間 9,909 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 208 ms
42,180 KB
testcase_07 AC 200 ms
42,176 KB
testcase_08 AC 203 ms
42,108 KB
testcase_09 AC 200 ms
42,168 KB
testcase_10 AC 198 ms
42,160 KB
testcase_11 WA -
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 207 ms
42,164 KB
testcase_21 AC 199 ms
42,172 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint=modint998244353; //1000000007;
using ll=long long;
using pp=pair<int,int>;
#define sr string 
#define vc vector
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define pque priority_queue
#define bpc(a) __builtin_popcount(a)
int main(){
  int n,m,kk;cin>>n>>m>>kk;
  vc d(n,vc<ll>(n,1e18));
  vc<ll>x(n); rep(i,n)cin>>x[i];
  rep(i,m){
    int a,b,c;cin>>a>>b>>c; a--;b--;
    d[a][b]=c; d[b][a]=c;
  }
  rep(i,n)rep(j,n)rep(k,n)d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
  vc dp(n,vc<ll>(1<<n,1e18)); 
  rep(i,n)dp[i][1<<i]=x[i];
  rep(i,1<<n)rep(j,n){
    rep(k,n)if(~i>>k&1){
      dp[k][i|1<<k]=min(dp[k][i|1<<k],dp[j][i]+x[k]+d[j][k]);
    }
  }
  ll ans=1e18;
  rep(i,1<<n)if(bpc(i)==kk)rep(j,n)ans=min(ans,dp[j][i]);
  cout<<ans;
}
    
0