結果
| 問題 |
No.807 umg tours
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-03-23 21:30:25 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,358 bytes |
| コンパイル時間 | 1,753 ms |
| コンパイル使用メモリ | 169,864 KB |
| 実行使用メモリ | 814,208 KB |
| 最終ジャッジ日時 | 2024-09-24 17:55:07 |
| 合計ジャッジ時間 | 4,868 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 WA * 7 MLE * 1 -- * 14 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define INF 1e9
typedef long long ll;
typedef pair<int, int> P;
typedef struct{
int first;
int second;
int third;
}T;
//昇順
bool comp_Se(T& l, T& r){
return l.second < r.second;
}
int N,M;
vector< vector<int> > cost;
vector<pair<int,int> > d;
vector<bool> used;
vector<int> ticket;
void dijkstra(){
while(true){
int v = -1;
//まだ使われていない頂点のうち距離が最小のものを探す
for(int u = 0; u < N; u++){
if(!used[u] && (v == -1 || d[u].first < d[v].first) ) v = u;
}
if( v == -1) break;
used[v] = true;
for(int u = 0; u < N; u++){
if(cost[u][v] != INF){
d[u].first = min(d[u].first, d[v].first+cost[v][u]);
d[u].second = min(d[u].second, d[v].second + min(ticket[v],cost[u][v]));
ticket[u] = max(ticket[v],cost[u][v]);
}
}
}
}
int main(void){
cin >> N >> M;
cost = vector<vector<int> >(M, vector<int>(M, INF));
d = vector<pair<int,int> >(N,pair<int,int>(INF,INF));
d[0] = pair<int,int>(0,0);
used = vector<bool>(M,false);
ticket = vector<int>(M,0);
int i;
REP(i,M){
int x,y,z;
cin >> x >> y >> z;
cost[x-1][y-1] = z;
cost[y-1][x-1] = z;
}
dijkstra();
REP(i,N){
cout << d[i].first+d[i].second << endl;
}
return 0;
}