結果

問題 No.2387 Yokan Factory
ユーザー hiroshi tamurahiroshi tamura
提出日時 2023-07-21 23:56:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 2,267 bytes
コンパイル時間 1,985 ms
コンパイル使用メモリ 138,288 KB
実行使用メモリ 644,356 KB
最終ジャッジ日時 2023-10-21 23:53:24
合計ジャッジ時間 9,307 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 MLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx,avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <memory>
#include <cstdlib>
#include <cstring>
#include <cmath>
//#include <boost/multiprecision/cpp_int.hpp>
#include <memory>



using namespace std;
using ll = long long int;
//// 任意長整数型
//namespace mp = boost::multiprecision;
//using Bint = mp::cpp_int;


struct Souko {
	ll to;
	ll a;
	ll b;
};



void Solve(const vector<vector<Souko>>& edges, const ll limitTime, const ll currentTime, const ll goalSoukoIndex, const ll currentSoukoIndex, const ll currentYokanSize, const vector<bool> visited, ll &maxYokanSize)
{

	if (goalSoukoIndex == currentSoukoIndex) {
		maxYokanSize = max(maxYokanSize, currentYokanSize);
		return;
	}

	

	const vector<Souko>& currentSouko = edges[currentSoukoIndex];
	for (int i = 0; i < currentSouko.size(); ++i) {

		ll nextSoukoIndex = currentSouko[i].to;
		ll nextTime = currentTime + currentSouko[i].a;
		ll nextYokanSize = min(currentYokanSize, currentSouko[i].b);

		if (limitTime < nextTime) {
			continue;
		}

		if (visited[nextSoukoIndex] == false) {
			vector<bool> nextVisited = visited;
			nextVisited[nextSoukoIndex] = true;

			Solve(edges, limitTime, nextTime, goalSoukoIndex, nextSoukoIndex, nextYokanSize, nextVisited, maxYokanSize);
		}

	}

	return;
}



int main()
{
	//input
	int N, M, X;
	cin >> N >> M >> X;

	vector<vector<Souko>> edges(N + 1);
	for (int i = 0; i < M; ++i) {
		ll u, v, a, b;
		cin >> u >> v >> a >> b;
		
		Souko souko1;
		souko1.to = v;
		souko1.a = a;
		souko1.b = b;
		edges[u].push_back(souko1);

		Souko souko2;
		souko2.to = u;
		souko2.a = a;
		souko2.b = b;
		edges[v].push_back(souko2);

	}

	vector<bool> visited(N + 1);
	for (int i = 0; i < N + 1; ++i) {
		visited[i] = false;
	}
	visited[1] = true;
	
	ll ans = -1;
	Solve(edges, X, 0, N, 1, LLONG_MAX, visited, ans);


	//ans
	cout << ans << endl;


	return 0;
}
0