結果
| 問題 |
No.1473 おでぶなおばけさん
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-10 03:35:36 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 277 ms / 2,000 ms |
| コード長 | 1,445 bytes |
| コンパイル時間 | 2,058 ms |
| コンパイル使用メモリ | 203,384 KB |
| 最終ジャッジ日時 | 2025-01-20 15:29:04 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 47 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
#include <cstdint>
#include <string>
#include <sstream>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using P=pair<int,int>;
const ll INF=1e18;
const int mod=1e9+7;
struct edge{
int to;
ll w;
edge(int to,ll w):to(to),w(w){}
};
int main(){
ll n,m;
cin>>n>>m;
vector<vector<edge>>G(n);
rep(i,m){
int s,t,d;
cin>>s>>t>>d;
s--;t--;
G[s].push_back(edge(t,d));
G[t].push_back(edge(s,d));
}
auto f=[&](ll W){
vector<ll>dist(n,INF);
dist[0]=0;
queue<ll>q;
q.push(0);
while(!q.empty()){
auto p=q.front();q.pop();
for(auto u:G[p]){
if(dist[u.to]==INF&&u.w>=W){
q.push(u.to);
dist[u.to]=dist[p]+1;
}
}
}
return dist[n-1];
};
ll l=0,r=1e9+5;
ll len=INF;
while(r-l>1){
ll mid=(l+r)/2;
ll dist=f(mid);
if(dist!=INF){l=mid;len=dist;}
else{r=mid;}
}
cout<<l<<" "<<len<<endl;
return 0;
}