結果
| 問題 |
No.788 トラックの移動
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-02-08 22:46:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,241 bytes |
| コンパイル時間 | 873 ms |
| コンパイル使用メモリ | 86,492 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-01 11:40:36 |
| 合計ジャッジ時間 | 3,732 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 12 WA * 2 |
コンパイルメッセージ
main.cpp:38:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
38 | main()
| ^~~~
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<vector>
#include<queue>
#include<limits>
template<typename T>
vector<T>dijkstra(int s,const vector<vector<pair<int,T> > >&G,T INF=numeric_limits<T>::max())
{
int n=G.size();
vector<T>d(n,INF);
vector<int>parent(n,-1);
priority_queue<pair<T,int>,vector<pair<T,int> >,greater<pair<T,int> > >P;
d[s]=0;
P.push(make_pair(d[s],s));
while(!P.empty())
{
pair<T,int>p=P.top();P.pop();
int v=p.second;
if(d[v]<p.first)continue;
for(const pair<int,T>&e:G[v])
{
int u=e.first;
T cost=d[v]+e.second;
if(d[u]>cost)
{
d[u]=cost;
parent[u]=v;
P.push(make_pair(d[u],u));
}
}
}
return d;
}
int n,m,L;
long t[2000];
main()
{
cin>>n>>m>>L;
for(int i=0;i<n;i++)cin>>t[i];
vector<vector<pair<int,long> > >G(n);
for(int i=0;i<m;i++)
{
int a,b;long c;cin>>a>>b>>c;
a--;b--;
G[a].push_back(make_pair(b,c));
G[b].push_back(make_pair(a,c));
}
vector<long>off=dijkstra(L-1,G);
long ans=9e18;
for(int i=0;i<n;i++)
{
long now=0;
long ofset=off[i];
vector<long>a=dijkstra(i,G);
for(int j=0;j<n;j++)
{
now+=t[j]*a[j]*2;
ofset=min(ofset,off[j]-a[j]);
}
ans=min(ans,now+ofset);
}
cout<<ans<<endl;
}