結果
問題 |
No.807 umg tours
|
ユーザー |
|
提出日時 | 2019-04-20 01:54:25 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,395 bytes |
コンパイル時間 | 1,068 ms |
コンパイル使用メモリ | 89,472 KB |
実行使用メモリ | 20,000 KB |
最終ジャッジ日時 | 2024-09-24 17:59:10 |
合計ジャッジ時間 | 7,211 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 WA * 12 |
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 8 | main() | ^~~~
ソースコード
#include<iostream> #include<vector> #include<algorithm> #include<queue> using namespace std; int N,M; vector<pair<int,int> >G[1<<17]; main() { cin>>N>>M; for(int i=0;i<M;i++) { int a,b,c;cin>>a>>b>>c; G[a-1].push_back(make_pair(b-1,c)); G[b-1].push_back(make_pair(a-1,c)); } vector<long>d1(N,9e18),d2(N,9e18); d1[0]=0; priority_queue<pair<pair<long,int>,int> >P; P.push(make_pair(make_pair(0,0),0)); while(!P.empty()) { long c=-P.top().first.first; int u=P.top().second; int m=-P.top().first.second; P.pop(); if(d1[u]<c)continue; for(int i=0;i<G[u].size();i++) { long next=c; if(G[u][i].second<m) { next+=G[u][i].second; if(d1[G[u][i].first]>next) { d1[G[u][i].first]=next; P.push(make_pair(make_pair(-next,-m),G[u][i].first)); } } else { next+=m; if(d1[G[u][i].first]>next) { d1[G[u][i].first]=next; P.push(make_pair(make_pair(-next,-G[u][i].second),G[u][i].first)); } } } } d2[0]=0; priority_queue<pair<long,int> >P2; P2.push(make_pair(0,0)); while(!P2.empty()) { long c=-P2.top().first; int u=P2.top().second; P2.pop(); if(d2[u]<c)continue; for(int i=0;i<G[u].size();i++) { int v=G[u][i].first; long next=G[u][i].second+c; if(d2[v]>next) { d2[v]=next; P2.push(make_pair(-next,v)); } } } for(int i=0;i<N;i++) { cout<<d1[i]+d2[i]<<endl; } }