結果
問題 | No.2387 Yokan Factory |
ユーザー |
|
提出日時 | 2023-07-21 21:39:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 313 ms / 5,000 ms |
コード長 | 896 bytes |
コンパイル時間 | 1,932 ms |
コンパイル使用メモリ | 206,396 KB |
最終ジャッジ日時 | 2025-02-15 16:36:08 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;using P = pair<ll, int>;using T = tuple<ll, ll, int>;int main () {int N, M; ll X;cin >> N >> M >> X;std::vector<T> gr[100020];for (int i = 0; i < M; i ++) {int u, v; ll a, b;cin >> u >> v >> a >> b;gr[--u].emplace_back(b, a, --v);gr[v].emplace_back(b, a, u);}ll ok = -1; ll ng = 1e9 + 7;vector<ll> D(N);while (abs(ok - ng) > 1) {ll mu = (ok + ng) / 2;priority_queue<P, vector<P>, greater<P>> pque;D.assign(N, X + 100);D[0] = 0;pque.emplace(0, 0);while (!pque.empty()) {auto [l, u] = pque.top();pque.pop();if (l != D[u]) continue;for (auto [b, a, v] : gr[u]) {if (b < mu) continue;if (D[v] > D[u] + a) {D[v] = D[u] + a;pque.emplace(D[v], v);}}}if (D[N - 1] > X) {ng = mu;} else {ok = mu;}}cout << ok << endl;}