結果
問題 | No.2387 Yokan Factory |
ユーザー |
![]() |
提出日時 | 2023-07-21 21:32:58 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 315 ms / 5,000 ms |
コード長 | 1,465 bytes |
コンパイル時間 | 2,225 ms |
コンパイル使用メモリ | 205,756 KB |
最終ジャッジ日時 | 2025-02-15 16:25:36 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include <bits/stdc++.h>using namespace std;#ifdef tabr#include "library/debug.cpp"#else#define debug(...)#endifint main() {ios::sync_with_stdio(false);cin.tie(nullptr);int n, m;long long f;cin >> n >> m >> f;vector<int> x(m), y(m), a(m), b(m);vector<vector<int>> g(n);for (int i = 0; i < m; i++) {cin >> x[i] >> y[i] >> a[i] >> b[i];x[i]--;y[i]--;g[x[i]].emplace_back(i);g[y[i]].emplace_back(i);}int low = -1, high = 1e9 + 10;while (high - low > 1) {auto mid = (high + low) >> 1;vector<long long> d(n, f + 1);priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> pq;d[0] = 0;pq.emplace(d[0], 0);while (!pq.empty()) {auto [dv, v] = pq.top();pq.pop();if (d[v] != dv) {continue;}for (int id : g[v]) {int to = x[id] ^ y[id] ^ v;if (b[id] < mid) {continue;}long long cost = d[v] + a[id];if (d[to] > cost) {d[to] = cost;pq.emplace(d[to], to);}}}if (d[n - 1] <= f) {low = mid;} else {high = mid;}}cout << low << '\n';return 0;}