結果
問題 | No.2387 Yokan Factory |
ユーザー |
|
提出日時 | 2023-07-21 21:39:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 485 ms / 5,000 ms |
コード長 | 1,194 bytes |
コンパイル時間 | 1,842 ms |
コンパイル使用メモリ | 183,956 KB |
実行使用メモリ | 12,928 KB |
最終ジャッジ日時 | 2024-09-21 23:02:40 |
合計ジャッジ時間 | 6,681 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;int main(){ios::sync_with_stdio(false);cin.tie(0);ll n, m, x, ok = -1, ng = 1ll << 30, mid;cin >> n >> m >> x;vector<vector<tuple<int, ll, ll>>> g(n);vector<ll> dist(n, 1ll << 60);for(int i = 0; i < m; i++){ll a, b, c, d;cin >> a >> b >> c >> d;a--, b--;g[a].emplace_back(b, c, d);g[b].emplace_back(a, c, d);}while(ok + 1 < ng){mid = (ok + ng) / 2;priority_queue<pair<ll,int>, vector<pair<ll,int>>, greater<pair<ll,int>>> pq;fill(dist.begin(), dist.end(), 1ll << 60);pq.emplace(0, 0);dist[0] = 0;while(!pq.empty()){ll d, c, e;int v, u;tie(d, v) = pq.top();pq.pop();if(dist[v] < d) continue;for(auto &&pa : g[v]){tie(u, c, e) = pa;if(e < mid) continue;if(d + c >= dist[u]) continue;dist[u] = d + c;pq.emplace(d + c, u);}}(dist[n - 1] <= x ? ok : ng) = mid;}cout << ok << '\n';}