QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#542595#8934. Challenge NPCucup-team1231#WA 0ms3984kbC++142.2kb2024-09-01 03:00:072024-09-01 03:00:08

Judging History

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

  • [2024-09-01 03:00:08]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3984kb
  • [2024-09-01 03:00:07]
  • 提交

answer

#include <bits/stdc++.h>
#include <queue>
using namespace std;
typedef long long LL;
namespace mcmf {
    const LL INF = 0x3f3f3f3f3f3f3f3fLL;
    int to[100005], c[100005], n, m;
    LL w[100005];
    vector<int> G[1005];
    void adde(int u, int v, int cap, LL cost) {
        to[m] = v; c[m] = cap; w[m] = cost;
        G[u].push_back(m++);
        to[m] = u; c[m] = 0; w[m] = -cost;
        G[v].push_back(m++);
    }
    LL dist[1005];
    int pre[1005];
    bool vis[1005];
    void dijk(int s) {
        priority_queue<pair<LL, int> > que;
        for(int i = 0; i < n; i++) {
            vis[i] = false; dist[i] = INF;
        }
        que.push(make_pair(0, s));
        dist[s] = 0;
        pre[s] = -1;
        while(!que.empty()) {
            int v = que.top().second; que.pop();
            if(vis[v]) continue;
            vis[v] = true;
            for(auto e : G[v]) if(c[e] > 0 && dist[to[e]] > dist[v] + w[e]) {
                dist[to[e]] = dist[v] + w[e];
                pre[to[e]] = e;
                que.push(make_pair(-dist[to[e]], to[e]));
            }
        }
    }
    LL solve(int s, int t, int f) {
        LL cd = 0, ret = 0;
        for(int i = 0; i < f; i++) {
            dijk(s);
            cd += dist[t];
            ret += cd;
            printf("%lld %lld\n", cd, ret);
            for(int j = 0; j < m; j++) w[j] += dist[to[j ^ 1]] - dist[to[j]];
            for(int v = t; v != s; v = to[pre[v] ^ 1]) {
                c[pre[v]]--; c[pre[v] ^ 1]++;
            }
        }
        return ret;
    }
}
int n, l[65], r[65], vn, w[65];
const int INF = 0x3f3f3f3f;

int main() {
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%d%d", &l[i], &r[i]);
    for(int i = 1; i <= n; i++) scanf("%d", &w[i]);

    vn = n + 2;
    for(int i = 0; i < n; i++) mcmf::adde(0, i + 2, 1, 0);
    for(int i = 1; i <= n; i++) for(int j = 0; j < n / i; j++) {
        for(int j = 0; j < n; j++) if(l[j] <= i && r[j] >= i) mcmf::adde(j + 2, vn, 1, 0);
        mcmf::adde(vn, 1, i, 1LL * i * INF + w[i]);
        vn++;
    }
    mcmf::n = vn;
    printf("%lld\n", mcmf::solve(0, 1, n) - 1LL * n * INF);
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3984kb

input:

1

output:

4557430888798830399 4557430888798830399
4557430887737720832

result:

wrong output format Expected int32, but "4557430888798830399" found