結果
| 問題 |
No.1473 おでぶなおばけさん
|
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2021-04-09 23:18:42 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,028 ms / 2,000 ms |
| コード長 | 1,294 bytes |
| コンパイル時間 | 2,519 ms |
| コンパイル使用メモリ | 212,464 KB |
| 最終ジャッジ日時 | 2025-01-20 15:12:12 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 47 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
const int INF=1e9+10;
struct Edge{
int to;
ll w;
Edge(int to,ll w) : to(to),w(w) {}
};
using Graph=vector<vector<Edge>>;
using pli=pair<ll,int>;
template<class T> bool chmin(T& a,T b){
if(a>b){
a=b;
return true;
}
return false;
}
int main(){
int n,m;
cin>>n>>m;
vector<int> S(m),T(m),D(m);
rep(i,m){
cin>>S[i]>>T[i]>>D[i];
S[i]--,T[i]--;
}
map<ll,ll> ma;
ll ok=0,ng=1e9+7;
while(ng-ok>1){
ll mid=(ok+ng)/2;
Graph G(n);
rep(i,m){
if(D[i]<mid) continue;
G[S[i]].push_back(Edge(T[i],1));
G[T[i]].push_back(Edge(S[i],1));
}
vector<ll> dist(n,INF);
int s=0;
dist[s]=0;
priority_queue<pli,vector<pli>,greater<pli>> que;
que.push({dist[s],s});
while(!que.empty()){
int v=que.top().second;
ll d=que.top().first;
que.pop();
if(d>dist[v]) continue;
for(auto e:G[v]){
if(chmin(dist[e.to],dist[v]+e.w)){
que.push({dist[e.to],e.to});
}
}
}
ma[mid]=dist[n-1];
if(dist[n-1]==INF) ng=mid;
else ok=mid;
}
cout<<ok<<" "<<ma[ok]<<endl;
return 0;
}
umezo