結果

問題 No.2387 Yokan Factory
ユーザー ripityripity
提出日時 2023-07-21 21:50:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,012 bytes
コンパイル時間 1,939 ms
コンパイル使用メモリ 216,660 KB
実行使用メモリ 10,708 KB
最終ジャッジ日時 2023-10-21 21:49:30
合計ジャッジ時間 6,737 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 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 226 ms
10,100 KB
testcase_16 AC 150 ms
10,460 KB
testcase_17 AC 350 ms
10,708 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 219 ms
6,872 KB
testcase_21 AC 400 ms
9,144 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 331 ms
7,896 KB
testcase_27 RE -
testcase_28 AC 4 ms
4,348 KB
testcase_29 AC 4 ms
4,348 KB
testcase_30 AC 3 ms
4,348 KB
testcase_31 AC 3 ms
4,348 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 4 ms
4,348 KB
testcase_35 AC 3 ms
4,348 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
	int N, M, X;
	cin >> N >> M >> X;
	vector<int> u(M), v(M), b(M);
	vector<long long> a(M);
	vector<vector<int>> G(N, vector<int>());
	for( int i = 0; i < M; i++ ) {
		cin >> u[i] >> v[i] >> a[i] >> b[i];
		u[i]--, v[i]--;
		G[u[i]].push_back(i);
		G[v[i]].push_back(i);
	}
	auto f = [&](int W) -> bool {
		vector<bool> vis(N, false);
		vector<long long> d(N, 1LL<<59);
		priority_queue<pair<long long, int>> que;
		d[0] = 0;
		que.push(make_pair(0, 0));
		while( !que.empty() ) {
			auto [_d, cur] = que.top();
			que.pop();
			if( vis[cur] ) continue;
			vis[cur] = true;
			for( int i : G[cur] ) {
				int nxt = u[i]^v[i]^cur;
				if( W <= b[i] && d[nxt] > d[cur]+a[i] ) {
					d[nxt] = d[cur]+a[i];
					que.push(make_pair(-d[nxt], nxt));
				}
			}
		}
		return d[N-1] <= X;
	};
	int ok = 0, ng = 1<<30;
	while( ok+1 < ng ) {
		int m = (ok+ng)/2;
		if( f(m) ) ok = m;
		else ng = m;
	}
	if( ok == 0 ) cout << -1 << endl;
	else cout << ok << endl;
}
0