QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#391659#3788. Funny Car Racingucup-team12510 0ms0kbC++171.3kb2024-04-16 17:57:552024-04-16 17:57:55

Judging History

你现在查看的是最新测评结果

  • [2024-04-16 17:57:55]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-04-16 17:57:55]
  • 提交

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();
        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});
        }
        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...

output:


result: