結果
| 問題 | No.3490 最高経路問題 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-04-03 21:56:49 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
AC
|
| 実行時間 | 85 ms / 2,000 ms |
| + 658µs | |
| コード長 | 747 bytes |
| 記録 | |
| コンパイル時間 | 2,125 ms |
| コンパイル使用メモリ | 342,348 KB |
| 実行使用メモリ | 11,008 KB |
| 最終ジャッジ日時 | 2026-08-25 03:58:37 |
| 合計ジャッジ時間 | 5,323 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 |
ソースコード
#include<bits/stdc++.h>
#define int long long
using namespace std;
int inf=1e18;
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,m;cin>>n>>m;
vector<vector<pair<int,int>>>g(n);
for(int i=0;i<m;i++){
int u,v,h;cin>>u>>v>>h;
u--;v--;
g[u].push_back({v,h});
g[v].push_back({u,h});
}
int ng=1e10,ok=0;
while(ng-ok>1){
int c=(ok+ng)/2;
vector<bool>vis(n);
vis[0]=true;
deque<int>que;
que.push_back(0);
while(!que.empty()){
int now=que.front();
que.pop_front();
for(auto to:g[now]){
if(c<=to.second&&!vis[to.first]){
vis[to.first]=true;
que.push_back(to.first);
}
}
}
if(vis[n-1])ok=c;
else ng=c;
}
if(ok==0){
cout<<"NaN"<<endl;
}else{
cout<<ok<<endl;
}
}