結果
問題 | No.1473 おでぶなおばけさん |
ユーザー |
![]() |
提出日時 | 2021-04-17 15:05:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 203 ms / 2,000 ms |
コード長 | 1,323 bytes |
コンパイル時間 | 4,166 ms |
コンパイル使用メモリ | 235,548 KB |
実行使用メモリ | 9,652 KB |
最終ジャッジ日時 | 2024-07-03 22:46:09 |
合計ジャッジ時間 | 12,643 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 47 |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; using ll=long long; using Graph=vector<vector<pair<int,int>>>; #define MOD 998244353 #define INF 1000000000 #define MAX 1000000 int main(){ int n,m; cin>>n>>m; Graph G(n); for(int i=0;i<m;i++){ int s,t,d; cin>>s>>t>>d; s--;t--; G[s].push_back(make_pair(t,d)); G[t].push_back(make_pair(s,d)); } int left=1; int right=1000000001; while(left+1<right){ int x=(left+right)/2; vector<int> dist(n,INF); dist[0]=0; queue<int> q; q.push(0); while(!q.empty()){ int v=q.front(); q.pop(); for(auto e:G[v]){ int nv=e.first; int d=e.second; if(d<x){ continue; } if(dist[nv]>dist[v]+1){ dist[nv]=dist[v]+1; q.push(nv); } } } if(dist[n-1]==INF){ right=x; }else{ left=x; } } int x=left; vector<int> dist(n,INF); dist[0]=0; queue<int> q; q.push(0); while(!q.empty()){ int v=q.front(); q.pop(); for(auto e:G[v]){ int nv=e.first; int d=e.second; if(d<x){ continue; } if(dist[nv]>dist[v]+1){ dist[nv]=dist[v]+1; q.push(nv); } } } cout<<x<<" "<<dist[n-1]<<endl; }