結果
| 問題 |
No.788 トラックの移動
|
| コンテスト | |
| ユーザー |
utouto97
|
| 提出日時 | 2019-02-08 23:09:41 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,620 bytes |
| コンパイル時間 | 1,531 ms |
| コンパイル使用メモリ | 169,792 KB |
| 実行使用メモリ | 34,780 KB |
| 最終ジャッジ日時 | 2024-07-01 11:43:47 |
| 合計ジャッジ時間 | 4,388 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 WA * 2 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:83:35: warning: ‘x’ may be used uninitialized in this function [-Wmaybe-uninitialized]
83 | ans = min(ans, tmp+lmin-d[i][x]);
| ~~~~~~^
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;
/*
*/
int n, m, l, t[2000];
vector<pii> es[2000];
ll d[2000][2000];
void dijkstra(int s)
{
priority_queue<pll, vector<pll>, greater<pll>> que;
fill(d[s], d[s]+n, linf);
d[s][s] = 0;
que.push(mp(0LL, s));
while(!que.empty()){
pll p = que.top();
que.pop();
if(d[s][p.second] < p.first) continue;
foreach(e, es[p.second]){
if(d[s][e.first] > d[s][p.second] + e.second){
d[s][e.first] = d[s][p.second] + e.second;
que.push(mp(d[s][e.first], e.first));
}
}
}
}
int main()
{
cin >> n >> m >> l;
rep(i, n){
cin >> t[i];
}
l--;
rep(i, m){
int a, b, c;
cin >> a >> b >> c;
a--; b--;
es[a].pb(mp(b, c));
es[b].pb(mp(a, c));
}
rep(i, n){
dijkstra(i);
}
ll ans = linf;
rep(i, n){
ll tmp = 0, lmin = d[l][i], x;
rep(j, n){
tmp += 2*t[j]*d[i][j];
if(t[j] > 0)
if(lmin > d[l][j]){
lmin = d[l][j];
x = j;
}
//lmin = min(lmin, d[l][j]);
}
ans = min(ans, tmp+lmin-d[i][x]);
}
cout << ans << endl;
return 0;
}
utouto97