結果

問題 No.2387 Yokan Factory
ユーザー polylogKpolylogK
提出日時 2023-08-02 23:36:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,447 bytes
コンパイル時間 2,515 ms
コンパイル使用メモリ 204,612 KB
実行使用メモリ 10,140 KB
最終ジャッジ日時 2024-04-20 23:28:52
合計ジャッジ時間 7,899 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 170 ms
9,820 KB
testcase_16 AC 87 ms
9,952 KB
testcase_17 AC 282 ms
10,140 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 188 ms
6,544 KB
testcase_21 AC 365 ms
8,708 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 152 ms
5,888 KB
testcase_26 AC 302 ms
7,588 KB
testcase_27 AC 358 ms
8,328 KB
testcase_28 AC 3 ms
5,376 KB
testcase_29 AC 4 ms
5,376 KB
testcase_30 AC 3 ms
5,376 KB
testcase_31 AC 3 ms
5,376 KB
testcase_32 AC 3 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 4 ms
5,376 KB
testcase_35 AC 4 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

#if defined(DONLINE_JUDGE)
	#define NDEBUG
#elif defined(ONLINE_JUDGE)
	#define NDEBUG
#endif

template<typename T> std::vector<T> make_v(size_t a){return std::vector<T>(a);}
template<typename T, typename... Ts> auto make_v(size_t a, Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

int main() {
	int n, m, x; scanf("%d%d%d", &n, &m, &x);
	std::vector<int> u(m), v(m), a(m), b(m);
	std::vector<std::vector<int>> g(n);
	for (int i = 0; i < m; ++i) {
		scanf("%d%d%d%d", &u[i], &v[i], &a[i], &b[i]);

		g[--u[i]].push_back(i);
		g[--v[i]].push_back(i);
	}

	auto f = [&](int t) {
		using P = std::pair<i64, int>;
		std::priority_queue<P, std::vector<P>, std::greater<P>> qu;

		std::vector<i64> costs(n, 1LL << 60); qu.push({costs[0] = 0, 0});
		while (!qu.empty()) {
			auto [cost, now] = qu.top(); qu.pop();
			if (costs[now] != cost) continue;

			for (int idx: g[now]) {
				int to = u[idx] ^ v[idx] ^ now;
				i64 nx = a[idx] + cost;
				if (b[idx] < t) continue;
				if (costs[to] <= nx) continue;

				qu.push({costs[to] = nx, to});
			}
		}

		return costs[n - 1] <= x;
	};

	int ok = -1, ng = 1 << 30;
	while (ng - ok > 1){
		int mid = (ok + ng) >> 1;

		if (f(mid)) ok = mid;
		else ng = mid;
	}

	printf("%d\n", ok);
	return 0;
}
0