結果

問題 No.2387 Yokan Factory
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2023-07-21 21:39:32
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 388 ms / 5,000 ms
コード長 896 bytes
コンパイル時間 2,326 ms
コンパイル使用メモリ 215,124 KB
実行使用メモリ 13,536 KB
最終ジャッジ日時 2024-09-21 23:02:47
合計ジャッジ時間 6,748 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0