結果
問題 | No.2387 Yokan Factory |
ユーザー | houren |
提出日時 | 2023-07-21 22:00:37 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 336 ms / 5,000 ms |
コード長 | 1,437 bytes |
コンパイル時間 | 1,595 ms |
コンパイル使用メモリ | 179,288 KB |
実行使用メモリ | 9,988 KB |
最終ジャッジ日時 | 2024-09-21 23:32:28 |
合計ジャッジ時間 | 5,659 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll,ll>; #define fix(x) fixed << setprecision(x) #define asc(x) x, vector<x>, greater<x> #define rep(i, n) for(ll i = 0; i < n; i++) #define all(x) (x).begin(),(x).end() template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;} template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;} constexpr ll INFLL = (1LL << 62), MOD = 998244353; constexpr int INF = (1 << 30); struct Edge{ int to,a,b; }; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); ll n,m,x; cin >> n >> m >> x; vector<vector<Edge>> g(n); rep(i,m){ int u,v,a,b; cin >> u >> v >> a >> b; u--; v--; g[u].push_back({v,a,b}); g[v].push_back({u,a,b}); } int ok = -1, ng = 1e9+1; while(ng-ok>1){ int md = (ok+ng)/2; vector<ll> dist(n,INFLL); dist[0] = 0; priority_queue<asc(P)> pq; pq.push({0,0}); while(pq.size()){ ll d,now; tie(d,now) = pq.top(); pq.pop(); if(dist[now]<d) continue; for(Edge e:g[now]){ if(md<=e.b){ if(chmin(dist[e.to], dist[now]+e.a)) pq.push({dist[e.to], e.to}); } } } if(dist[n-1]<=x) ok = md; else ng = md; } cout << ok << '\n'; return 0; }