結果
| 問題 |
No.2387 Yokan Factory
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-22 00:11:19 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,268 bytes |
| コンパイル時間 | 1,995 ms |
| コンパイル使用メモリ | 136,876 KB |
| 実行使用メモリ | 22,144 KB |
| 最終ジャッジ日時 | 2024-09-22 01:31:23 |
| 合計ジャッジ時間 | 8,931 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 TLE * 1 -- * 22 |
ソースコード
#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 {
int to;
int a;
int b;
};
void Solve(const vector<vector<Souko>>& edges, const ll& limitTime, const ll& currentTime, const int& goalSoukoIndex, const int& currentSoukoIndex, const int& currentYokanSize, vector<bool>& visited, int &maxYokanSize)
{
if (goalSoukoIndex == currentSoukoIndex) {
maxYokanSize = max(maxYokanSize, currentYokanSize);
return;
}
const vector<Souko>& currentSouko = edges[currentSoukoIndex];
for (int i = 0; i < currentSouko.size(); ++i) {
int nextSoukoIndex = currentSouko[i].to;
ll nextTime = currentTime + currentSouko[i].a;
int nextYokanSize = min(currentYokanSize, currentSouko[i].b);
if (limitTime < nextTime) {
continue;
}
if (visited[nextSoukoIndex] == false) {
visited[nextSoukoIndex] = true;
Solve(edges, limitTime, nextTime, goalSoukoIndex, nextSoukoIndex, nextYokanSize, visited, maxYokanSize);
visited[nextSoukoIndex] = false;
}
}
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) {
int 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;
int ans = -1;
Solve(edges, X, 0, N, 1, INT_MAX, visited, ans);
//ans
cout << ans << endl;
return 0;
}