結果
| 問題 |
No.788 トラックの移動
|
| コンテスト | |
| ユーザー |
kmjp
|
| 提出日時 | 2019-02-08 23:58:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,492 bytes |
| コンパイル時間 | 1,734 ms |
| コンパイル使用メモリ | 177,244 KB |
| 実行使用メモリ | 35,200 KB |
| 最終ジャッジ日時 | 2024-07-01 11:47:21 |
| 合計ジャッジ時間 | 4,728 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 12 WA * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
int N,M,L;
ll T[2020];
vector<pair<int,int>> E[2020];
ll D[2020][2020];
void solve() {
int i,j,k,l,r,x,y; string s;
cin>>N>>M>>L;
L--;
FOR(i,N) cin>>T[i];
FOR(x,N) FOR(y,N) D[x][y]=1LL<<60;
FOR(i,M) {
cin>>x>>y>>r;
E[x-1].push_back({y-1,r});
E[y-1].push_back({x-1,r});
}
ll mi=1LL<<60;
FOR(i,N) {
D[i][i]=0;
priority_queue<pair<ll,int>> PQ;
PQ.push({0,i});
while(PQ.size()) {
ll co=-PQ.top().first;
int cur=PQ.top().second;
PQ.pop();
if(D[i][cur]!=co) continue;
FORR(e,E[cur]) if(D[i][e.first]>D[i][cur]+e.second) {
D[i][e.first]=D[i][cur]+e.second;
PQ.push({-D[i][e.first],e.first});
}
}
}
FOR(i,N) {
ll tot=0;
ll del=-(1LL<<60);
FOR(x,N) if(T[x]) {
tot+=T[x]*D[i][x]*2;
del=max(del,D[L][x]-D[i][x]);
}
mi=min(mi,tot-del);
}
cout<<mi<<endl;
}
int main(int argc,char** argv){
string s;int i;
if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
cout.tie(0); solve(); return 0;
}
kmjp