QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#282380#3249. 分组作业kilo_tobo_tarjen#WA 28ms7824kbC++202.7kb2023-12-11 21:40:132023-12-11 21:40:14

Judging History

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

  • [2023-12-11 21:40:14]
  • 评测
  • 测评结果:WA
  • 用时:28ms
  • 内存:7824kb
  • [2023-12-11 21:40:13]
  • 提交

answer

#include <bits/stdc++.h>
// #include <bits/extc++.h>
// using namespace __gnu_cxx;
// using namespace __gnu_pbds;
using i64 = long long;
using namespace std;
const int N = 2e4 + 5;
// const int B = 1250;
const int M = 3e5 + 5;
// const int base = 17131;
// const int mod = 998244353;
// const int mod = 1e9 + 7;
// const long double pi = acosl(-1);

const i64 inf_flow = 1e9;
i64 cap[M];
int head[N], nxt[M], to[M], tot, S, T;
void add(int x, int y, i64 z)
{
    to[tot] = y, cap[tot] = z, nxt[tot] = head[x], head[x] = tot++;
    to[tot] = x, cap[tot] = 0, nxt[tot] = head[y], head[y] = tot++;
}
queue<int> que;
int dep[N], g[N];
bool bfs()
{
    for (int i = S; i <= T; i++)
        g[i] = -1, dep[i] = 0;
    que.push(S);
    dep[S] = 1;
    while (!que.empty())
    {
        int cur = que.front();
        que.pop();
        g[cur] = head[cur];
        for (int p = head[cur]; ~p; p = nxt[p])
        {
            if (!dep[to[p]] && cap[p])
            {
                dep[to[p]] = dep[cur] + 1;
                que.push(to[p]);
            }
        }
    }
    return dep[T] != 0;
}
i64 dfs(int cur, i64 flow)
{
    if (cur == T)
        return flow;
    i64 used = 0;
    for (int &p = g[cur]; ~p; p = nxt[p])
    {
        if (cap[p] && dep[to[p]] == dep[cur] + 1)
        {
            i64 k = dfs(to[p], min(flow - used, cap[p]));
            used += k;
            cap[p] -= k, cap[p ^ 1] += k;
            if (used == flow)
                return used;
        }
    }
    return used;
}

int n, m, c[N], d[N], e[N];
void solve()
{
    memset(head, -1, sizeof(head));
    cin >> n >> m;
    for (int i = 1; i <= n * 2; i++)
        cin >> c[i] >> d[i] >> e[i];
    S = 0, T = 3 * n + 1;
    for (int i = 1; i <= n; i++)
    {
        add(S, 3 * i - 2, inf_flow * 2 + c[2 * i - 1] + c[2 * i]);
        add(3 * i - 2, 3 * i - 1, inf_flow + c[2 * i - 1]);
        add(3 * i - 2, 3 * i, inf_flow + c[2 * i]);
        add(3 * i - 1, 3 * i, inf_flow + e[2 * i - 1]);
        add(3 * i, 3 * i - 1, inf_flow + e[2 * i]);
        add(3 * i - 1, T, inf_flow + d[2 * i - 1]);
        add(3 * i, T, inf_flow + d[2 * i]);
    }
    for (int i = 1, a, b, x, y; i <= m; i++)
    {
        cin >> a >> b >> x >> y;
        a = (a + 1) / 2, b = (b + 1) / 2;
        add(3 * a - 1, 3 * b - 2, x);
        add(3 * a - 2, 3 * b, y);
    }
    i64 ans = 0;
    while (bfs())
        ans += dfs(S, 1e18);
    ans -= inf_flow * n * 2;
    cout << ans << '\n';
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    // cin >> t;
    cout << fixed << setprecision(10);
    while (t--)
        solve();
}

详细

Test #1:

score: 0
Wrong Answer
time: 28ms
memory: 7824kb

input:

5000 10000
23060775 12 2
255978380 28 517
5 6624 26
151149 45131806 23849036
489 484971 24970
162846 1993316 188305
56311199 2003 211
1 50534913 517527
364913 882765 298
71 26 122914059
13 65459 18150033
20 607 8
380059068 3873712 228
9813 5449 6370
3309369 37410691 8
181 1 62340851
1705 4 107
8 209...

output:

33480347810

result:

wrong answer 1st lines differ - expected: '22929674417', found: '33480347810'