結果

問題 No.2387 Yokan Factory
ユーザー achapiachapi
提出日時 2023-07-21 21:56:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 573 ms / 5,000 ms
コード長 1,192 bytes
コンパイル時間 3,274 ms
コンパイル使用メモリ 212,868 KB
実行使用メモリ 13,184 KB
最終ジャッジ日時 2023-10-21 21:58:24
合計ジャッジ時間 7,870 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 264 ms
13,184 KB
testcase_16 AC 179 ms
12,156 KB
testcase_17 AC 366 ms
12,180 KB
testcase_18 AC 439 ms
11,080 KB
testcase_19 AC 310 ms
9,100 KB
testcase_20 AC 249 ms
8,500 KB
testcase_21 AC 573 ms
10,760 KB
testcase_22 AC 227 ms
8,068 KB
testcase_23 AC 327 ms
9,036 KB
testcase_24 AC 145 ms
8,420 KB
testcase_25 AC 186 ms
6,648 KB
testcase_26 AC 404 ms
9,728 KB
testcase_27 AC 497 ms
10,440 KB
testcase_28 AC 4 ms
4,348 KB
testcase_29 AC 5 ms
4,348 KB
testcase_30 AC 4 ms
4,348 KB
testcase_31 AC 4 ms
4,348 KB
testcase_32 AC 3 ms
4,348 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 4 ms
4,348 KB
testcase_35 AC 4 ms
4,348 KB
testcase_36 AC 3 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

struct Edge{
	int to;
	long long cost;
	long long cap;
};
using Graph = vector<vector<Edge>>;
using Pair = pair<long long, int>;

void Dijkstra(const Graph& graph, vector<long long>& distances, int startIndex, int cap){
	priority_queue<Pair, vector<Pair>, greater<Pair>> q;
	q.emplace((distances[startIndex] = 0), startIndex);
	while (!q.empty()){
		const long long distance = q.top().first;
		const int from = q.top().second;
		q.pop();
		if (distances[from] < distance)continue;
		for (const auto& edge : graph[from]){
			const long long d = (distances[from] + edge.cost);
			if (d < distances[edge.to] and edge.cap >= cap){
				q.emplace((distances[edge.to] = d), edge.to);
			}
		}
	}
}

int main() {
	int N, M;
	long long X;
	cin >> N >> M >> X;
	Graph G(N);
	for (int i = 0; i < M; i++){
		int u, v, a, b;
		cin >> u >> v >> a >> b;
		u--;
		v--;
		G[u].push_back({v, a, b});
		G[v].push_back({u, a, b});
	}
	int l = -1, r = 1e9 + 10;
	while (r - l > 1){
		int mid = l + (r - l) / 2;
		vector<long long> d(N, (long long) 1e15);
		Dijkstra(G, d, 0, mid);
		if (d[N - 1] <= X){
			l = mid;
		} else {
			r = mid;
		}
	}
	cout << l << '\n';
}
0