結果
| 問題 |
No.788 トラックの移動
|
| コンテスト | |
| ユーザー |
addeight2
|
| 提出日時 | 2019-02-09 16:17:25 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,092 bytes |
| コンパイル時間 | 1,409 ms |
| コンパイル使用メモリ | 166,920 KB |
| 実行使用メモリ | 34,944 KB |
| 最終ジャッジ日時 | 2024-07-01 19:14:22 |
| 合計ジャッジ時間 | 4,880 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 WA * 2 |
ソースコード
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
const int MAX_N=2e3;
const ll INF=1e18;
struct edge{
int to;
ll cst;
edge(int t=-1,ll c=0):to(t),cst(c){}
};
vector<edge> G[MAX_N];
int N,M,L;
ll t[MAX_N];
ll dst[MAX_N][MAX_N];
typedef pair<ll,int> P;
void dijk(int s){
REP(v,N)dst[s][v]=INF;
dst[s][s]=0;
priority_queue<P,vector<P>,greater<P> > pque;
pque.push(P(0,s));
while(!pque.empty()){
P p=pque.top();
pque.pop();
int v=p.second;
if(p.first>dst[s][v])continue;
for(auto e:G[v]){
if(dst[s][e.to]>dst[s][v]+e.cst){
dst[s][e.to]=dst[s][v]+e.cst;
pque.push(P(dst[s][e.to],e.to));
}
}
}
}
int main(){
cin>>N>>M>>L;
L--;
REP(i,N)cin>>t[i];
REP(i,M){
int a,b;
ll c;
cin>>a>>b>>c;
a--;
b--;
G[a].push_back(edge(b,c));
G[b].push_back(edge(a,c));
}
REP(i,N){
dijk(i);
}
ll ans=INF;
REP(v,N){
ll sm=0;
REP(i,N){
sm+=2*t[i]*dst[v][i];
}
REP(u,N){
if(t[u]>0){
ans=min(ans,sm+dst[L][u]-dst[u][v]);
}
}
}
cout<<ans<<endl;
}
addeight2