結果
| 問題 |
No.1473 おでぶなおばけさん
|
| コンテスト | |
| ユーザー |
ysystem7
|
| 提出日時 | 2021-04-10 14:41:50 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 462 ms / 2,000 ms |
| コード長 | 2,275 bytes |
| コンパイル時間 | 3,950 ms |
| コンパイル使用メモリ | 219,552 KB |
| 最終ジャッジ日時 | 2025-01-20 15:39:23 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 47 |
ソースコード
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
//#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline void out(T a){ cout << a << '\n'; }
void YN(bool ok){if(ok) cout << "Yes" << endl; else cout << "No" << endl;}
//void YN(bool ok){if(ok) cout << "YES" << endl; else cout << "NO" << endl;}
const ll INF=1e18;
const int mx=200005;
struct edge{
ll to,cost;
};
int main(){
//オーバーフローは大丈夫ですか??
cin.tie(0);ios::sync_with_stdio(false);
int n,m;
cin>>n>>m;
V<V<edge>> G(n);
rep(i,m){
ll s,t,d;
cin>>s>>t>>d;
s--;t--;
G[s].pb({t,d});
G[t].pb({s,d});
}
ll L=0,R=1000000000+1;
ll ans=INF;
while(R-L>1){
ll mid=(L+R)/2;
V<int> d(n,-1);
queue<int> que;
que.push(0);
d[0]=0;
while(que.size()){
int v=que.front();
que.pop();
for(edge e:G[v]){
int nv=e.to;
if(d[nv]!=-1) continue;
if(mid<=e.cost){
d[nv]=d[v]+1;
que.push(nv);
}
}
}
if(d[n-1]>=0){
L=mid;
ans=d[n-1];
}else{
R=mid;
}
}
cout<<L<<' '<<ans<<endl;
}
//ペナルティ出しても焦らない ACできると信じろ!!!
//どうしてもわからないときはサンプルで実験 何か見えてくるかも
//頭で考えてダメなら紙におこせ!!
ysystem7