QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#391635 | #3788. Funny Car Racing | ucup-team1251 | 0 | 0ms | 0kb | C++17 | 1.5kb | 2024-04-16 17:47:13 | 2024-04-16 17:47:14 |
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;
set<int> dist[310];
int n, m, s, ed;
int tp;
struct node {
int x, a, b, t;
};
vector<node> e[310];
void dijkstra() {
priority_queue<PII, vector<PII>, greater<PII> > q;
q.push({0, s});
dist[s].insert(0);
while (q.size()) {
int ti = q.top().fi, ver = q.top().se;
q.pop();
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 (time > 61000) {
continue;
}
if (!dist[j].count(time)) {
dist[j].insert(time);
q.push({time, j});
}
}
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
while (cin >> n >> m >> s >> ed) {
for (int i = 1; i <= n; i++) {
dist[i].clear();
e[i].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});
}
dijkstra();
int ans = *dist[ed].begin();
printf("Case %lld: %lld\n", ++tp, ans);
}
}
详细
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...