QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#282389 | #3249. 分组作业 | kilo_tobo_tarjen# | WA | 32ms | 8080kb | C++20 | 2.7kb | 2023-12-11 22:01:04 | 2023-12-11 22:01:04 |
Judging History
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, i + 2 * n, inf_flow * 2 + c[2 * i - 1] + c[2 * i]);
add(i + 2 * n, 2 * i - 1, inf_flow + c[2 * i - 1]);
add(i + 2 * n, 2 * i, inf_flow + c[2 * i]);
add(2 * i - 1, 2 * i, inf_flow + e[2 * i - 1]);
add(2 * i, 2 * i - 1, inf_flow + e[2 * i]);
add(2 * i - 1, T, inf_flow + d[2 * i - 1]);
add(2 * i, T, inf_flow + d[2 * i]);
}
for (int i = 1, a, b, x, y; i <= m; i++)
{
cin >> a >> b >> x >> y;
int aa = (a + 1) / 2, bb = (b + 1) / 2;
add(a, bb + 2 * n, x);
add(aa + 2 * n, 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: 32ms
memory: 8080kb
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'