結果
問題 |
No.1473 おでぶなおばけさん
|
ユーザー |
|
提出日時 | 2021-04-09 21:37:21 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 183 ms / 2,000 ms |
コード長 | 1,060 bytes |
コンパイル時間 | 856 ms |
コンパイル使用メモリ | 79,504 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-06-25 04:33:56 |
合計ジャッジ時間 | 7,921 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 47 |
コンパイルメッセージ
main.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 10 | main() | ^~~~
ソースコード
#include<iostream> #include<queue> #include<vector> #include<algorithm> using namespace std; int N,M; vector<pair<int,int> >G[1<<17]; int dist[1<<17]; int cnt[1<<17]; main() { cin>>N>>M; for(int i=0;i<M;i++) { int u,v,d;cin>>u>>v>>d; u--,v--; G[u].push_back(make_pair(v,d)); G[v].push_back(make_pair(u,d)); } dist[0]=2e9; priority_queue<pair<int,int> >P; P.push(make_pair(dist[0],0)); while(!P.empty()) { int cost=P.top().first; int u=P.top().second; P.pop(); if(dist[u]>cost)continue; for(pair<int,int>e:G[u]) { int v=e.first; int nxt=min(cost,e.second); if(dist[v]<nxt) { dist[v]=nxt; P.push(make_pair(nxt,v)); } } } int W=dist[N-1]; for(int i=0;i<N;i++)cnt[i]=1e9; cnt[0]=0; P.push(make_pair(0,0)); while(!P.empty()) { int cost=-P.top().first; int u=P.top().second; P.pop(); if(cnt[u]<cost)continue; for(pair<int,int>e:G[u])if(e.second>=W) { int v=e.first; if(cnt[v]>cost+1) { cnt[v]=cost+1; P.push(make_pair(-cnt[v],v)); } } } cout<<W<<" "<<cnt[N-1]<<endl; }