結果

問題 No.2387 Yokan Factory
ユーザー shobonvipshobonvip
提出日時 2023-07-21 21:43:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 806 ms / 5,000 ms
コード長 1,595 bytes
コンパイル時間 4,600 ms
コンパイル使用メモリ 277,432 KB
実行使用メモリ 13,484 KB
最終ジャッジ日時 2023-10-21 21:41:51
合計ジャッジ時間 13,274 ms
ジャッジサーバーID
(参考情報)
judge9 / 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 383 ms
13,484 KB
testcase_16 AC 272 ms
12,428 KB
testcase_17 AC 504 ms
13,268 KB
testcase_18 AC 732 ms
12,428 KB
testcase_19 AC 507 ms
9,344 KB
testcase_20 AC 350 ms
8,288 KB
testcase_21 AC 794 ms
11,900 KB
testcase_22 AC 335 ms
8,024 KB
testcase_23 AC 547 ms
9,216 KB
testcase_24 AC 349 ms
8,552 KB
testcase_25 AC 304 ms
6,968 KB
testcase_26 AC 655 ms
11,108 KB
testcase_27 AC 806 ms
11,900 KB
testcase_28 AC 4 ms
4,348 KB
testcase_29 AC 7 ms
4,348 KB
testcase_30 AC 6 ms
4,348 KB
testcase_31 AC 4 ms
4,348 KB
testcase_32 AC 4 ms
4,348 KB
testcase_33 AC 4 ms
4,348 KB
testcase_34 AC 6 ms
4,348 KB
testcase_35 AC 5 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>
#include<atcoder/all>
using namespace std;
using namespace atcoder;

typedef modint998244353 mint;
typedef long long ll;

#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)

template <typename T> bool chmin(T &a, const T &b) {
	if (a <= b) return false;
	a = b;
	return true;
}
template <typename T> bool chmax(T &a, const T &b) {
	if (a >= b) return false;
	a = b;
	return true;
}

ll dijk(int n, vector<vector<pair<int,ll>>> &ikeru){
	const ll inf = (1e18) + 50;
	vector<ll> d(n, inf);
	d[0] = 0;
	priority_queue<pair<ll,int>> pq;
	pq.push(pair(0, 0));
	while(!pq.empty()){
		auto [tmp, i] = pq.top();
		pq.pop();
		tmp = -tmp;
		if (tmp > d[i]) continue;
		for (auto [j, dist] : ikeru[i]){
			ll targ = dist + tmp;
			if (targ < d[j]){
				d[j] = targ;
				pq.push(pair(-targ, j));
			}
		}
	}
	return d[n-1];
}

int main(){
	int n, m; cin >> n >> m;
	ll x; cin >> x;
	//vector ikeru(n, vector<pair<int,ll>>(0));
	vector<tuple<int,int,ll,ll>> edge;
	rep(i,0,m){
		int u, v; cin >> u >> v; u--; v--;
		ll a, b; cin >> a >> b;
		edge.push_back(make_tuple(u, v, a, b));
	}
	int lb = -1;
	int ub = 1e9 + 6;
	while (ub - lb > 1){
		int targ = (lb + ub) / 2;
		vector ikeru(n, vector<pair<int,ll>>(0));
		for (auto [u, v, a, b] : edge){
			if (b >= targ){
				ikeru[u].push_back(pair(v, a));
				ikeru[v].push_back(pair(u, a));
			}
		}
		//cout << dijk(n, ikeru) << " " << x << " " << targ << '\n';
		if (dijk(n, ikeru) <= x){
			lb = targ;
		}else{
			ub = targ;
		}
	}
	cout << lb << '\n';
}
0