QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#391679 | #3788. Funny Car Racing | ucup-team1251 | 0 | 0ms | 0kb | C++17 | 1.4kb | 2024-04-16 18:00:19 | 2024-04-16 18:00:19 |
answer
// #pragma GCC optimize(2) //O2优化开启
#include <bits/stdc++.h>
#define fi first
#define se second
#define int long long
using namespace std;
typedef long long i64;
typedef pair<int, int> PII;
typedef unsigned long long ull;
int n, m, st, ed;
int tp;
set<PII> bj;
set<int> ans;
struct node {
int x, a, b, t;
};
vector<node> e[310];
void dfs(int ver, int ti) {
for (auto &[j, a, b, t] : e[ver]) {
if (a < t) {
continue;
}
int tt = ti % (a + b);
int time;
if (tt + t <= a) {
time = ti + t;
} else {
time = ti - tt + a + b + t;
}
if (!bj.count({j, time})) {
if (j == ed) {
ans.insert(time);
}
bj.insert({j, time});
dfs(j, time);
}
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
while (cin >> n >> m >> st >> ed) {
for (int i = 1; i <= n; i++) {
e[i].clear();
}
bj.clear();
ans.clear();
for (int i = 0; i < m; i++) {
int u, v, a, b, t;
cin >> u >> v >> a >> b >> t;
e[u].push_back({v, a, b, t});
}
if (st == ed) {
printf("Case %lld: %lld\n", ++tp, 0);
}
dfs(st, 0);
int an;
for (auto &i : ans) {
an = i;
break;
}
printf("Case %lld: %lld\n", ++tp, an);
}
}
詳細信息
Test #1:
score: 0
Time Limit Exceeded
input:
155 9507 117 14 19 18 2 123 1 100 97 4 155 3 121 120 1 140 1 5 8 1 121 1 69 66 2 107 2 151 150 2 190 1 68 69 1 101 1 61 60 2 126 1 124 127 2 160 3 59 55 5 133 4 66 67 1 189 1 94 96 2 108 2 65 63 2 181 2 44 48 1 130 1 28 29 1 180 1 5 6 1 107 1 29 28 1 120 1 142 140 4 152 2 46 45 2 113 1 85 88 6 163 3...