結果

問題 No.2387 Yokan Factory
ユーザー Kinoko_SokoraKinoko_Sokora
提出日時 2023-07-21 21:47:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 305 ms / 5,000 ms
コード長 2,721 bytes
コンパイル時間 1,497 ms
コンパイル使用メモリ 140,032 KB
実行使用メモリ 10,120 KB
最終ジャッジ日時 2023-10-21 21:47:20
合計ジャッジ時間 5,249 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 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 1 ms
4,348 KB
testcase_15 AC 164 ms
10,120 KB
testcase_16 AC 91 ms
9,308 KB
testcase_17 AC 247 ms
9,556 KB
testcase_18 AC 213 ms
9,140 KB
testcase_19 AC 196 ms
7,316 KB
testcase_20 AC 158 ms
6,964 KB
testcase_21 AC 305 ms
8,732 KB
testcase_22 AC 149 ms
6,692 KB
testcase_23 AC 209 ms
7,348 KB
testcase_24 AC 81 ms
6,800 KB
testcase_25 AC 127 ms
5,784 KB
testcase_26 AC 231 ms
7,780 KB
testcase_27 AC 275 ms
8,552 KB
testcase_28 AC 2 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 3 ms
4,348 KB
testcase_35 AC 2 ms
4,348 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<stack>
#include<iomanip>
#include<queue>
#include<set>
#include<functional>
#include<tuple>
#include<bitset>
#include<cassert>
#include<cstdint>
#include<complex>
#include<random>
using namespace std;
bool printb(bool f) {
	if (f)printf("Yes\n");
	else printf("No\n");
	return f;
}
template<class T>
void prt(T t = "", string sep = "\n") { cout << t << sep; return; }
template<class T>
void printl(vector<T> a, string sep = " ") {
	for (int i = 0; i < a.size(); i++) {
		cout << a[i];
		if (i != a.size() - 1)cout << sep;
	}
	if (sep != "\n")cout << "\n";
	return;
}
bool prt_isfixed = false;
template<class T>
void prt_fix(T t, string sep = "\n") {
	if (!prt_isfixed) {
		cout << fixed << setprecision(15);
		prt_isfixed = true;
	}
	prt(t, sep);
}
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using uint = unsigned int;
using llong = long long;
using ullong = unsigned long long;
using pii = pair<int, int>;
using pll = pair<llong, llong>;
using pli = pair<llong, int>;
using pil = pair<int, llong>;
template<typename T> using vec2 = vector<vector<T>>;
template<typename T> inline bool chmin(T& a, T b) { return (a > b) ? (a = b, true) : false; }
template<typename T> inline bool chmax(T& a, T b) { return (a < b) ? (a = b, true) : false; }
bool bitIn(llong a, int b) { return ((a >> b) & 1); }
int bitCnt(llong a) {
	int re = 0;
	while (a > 0) {
		if (a & 1)re++;
		a >>= 1;
	}
	return re;
}
llong powL(llong n, llong i) {
	llong re = 1;
	while (i >= 1) {
		if (i & 1) re *= n;
		n *= n;
		i >>= 1;
	}
	return re;
}

llong powL_M(llong n, llong i, llong mod) {
	llong re = 1;
	while (i >= 1) {
		if (i & 1) {
			re *= n;
			re %= mod;
		}
		n *= n;
		n %= mod;
		i >>= 1;
	}
	return re;
}

int  dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int dx8[8] = { 0,1,1,1,0,-1,-1,-1 }, dy8[8] = { -1,-1,0,1,1,1,0,-1 };



int main() {
	int n, m;
	llong x;
	cin >> n >> m >> x;
	using T = tuple<int, int, int>;
	vec2<T> g(n);
	rep(i, m) {
		int u, v, a, b;
		scanf("%d %d %d %d", &u, &v, &a, &b);
		u--; v--;
		g[u].emplace_back(v, a, b);
		g[v].emplace_back(u, a, b);
	}

	int ok = -1, ng = 1e9 + 100;
	while (abs(ok - ng) != 1) {
		int mid = (ok + ng) / 2;
		priority_queue<pli, vector<pli>, greater<pli>> q;
		q.emplace(0, 0);
		vector<llong> dis(n,1e18);
		dis[0] = 0;
		while (!q.empty()) {
			auto [d, v] = q.top(); q.pop();
			if (dis[v]< d)continue;

			for (auto [to, co, wid] : g[v]) {
				if (wid < mid)continue;
				if (chmin(dis[to], dis[v] + co))q.emplace(dis[v] + co, to);
			}
		}
		if (dis[n - 1] >x)ng = mid;
		else ok = mid;
	}
	prt(ok);
}

0