比赛 2025暑期集训第5场图论专场 评测结果 AAAAAAAAAA
题目名称 Milk Pumping 最终得分 100
用户昵称 健康铀 运行时间 0.552 s
代码语言 C++ 内存使用 3.69 MiB
提交时间 2025-07-09 09:31:45
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3f;

int main() {
    freopen("pump.in", "r", stdin);
    freopen("pump.out", "w", stdout);

    int N, M;
    cin >> N >> M;
    vector<tuple<int, int, int, int>> E;
    for (int i = 0; i < M; i++) {
        int a, b, c, f;
        cin >> a >> b >> c >> f;
        E.emplace_back(a, b, c, f);
    }

    LL ans = 0;
    for (int f = 1; f <= 1000; f++) {
        vector<vector<pair<int, int>>> G(N + 1);
        for (auto& [a, b, c, fl] : E) {
            if (fl >= f) {
                G[a].push_back({b, c});
                G[b].push_back({a, c});
            }
        }

        vector<LL> D(N + 1, INF);
        priority_queue<pair<LL, int>, vector<pair<LL, int>>, greater<>> Q;
        D[1] = 0;
        Q.push({0, 1});
        while (!Q.empty()) {
            auto [d, u] = Q.top();
            Q.pop();
            if (d != D[u]) continue;
            for (auto& [v, c] : G[u]) {
                if (D[u] + c < D[v]) {
                    D[v] = D[u] + c;
                    Q.push({D[v], v});
                }
            }
        }

        if (D[N] != INF) {
            LL val = (LL)f * 1000000LL / D[N];
            if (val > ans) ans = val;
        }
    }
    cout << ans << endl;
    return 0;
}