QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#43668 | #3249. 分组作业 | _Dusker | WA | 88ms | 46132kb | C++14 | 2.5kb | 2022-08-09 21:48:49 | 2022-08-09 21:48:50 |
Judging History
answer
#include<bits/stdc++.h>
#define ioclear std::ios::sync_with_stdio(false);std::cin.tie(nullptr);std::cout.tie(nullptr);
#define endl '\n'
//#define int long long
using i64 = long long;
template<typename T>
struct Flow
{
static constexpr T inf = 1E17;
static constexpr int mmax = 1E6 + 10;
int n, m, s, t;
T dis[mmax], ptr[mmax];
Flow(int _n, int _m, int _s, int _t) : n(_n), m(_m), s(_s), t(_t) {}
Flow() {}
struct node
{
int from, to;
T cap, flow;
node() {}
node(int u, int v, T w, T f) : from(u), to(v), cap(w), flow(f) {}
};
std::vector<node> edge;
std::vector<int> no[mmax];
void set(int _n, int _m, int _s, int _t) {n = _n, m = _m, s = _s, t = _t;}
void add(int u, int v, T w)
{
no[u].push_back(edge.size());
edge.push_back({u, v, w, 0});
no[v].push_back(edge.size());
edge.push_back({v, u, 0, 0});
return;
}
bool bfs()
{
memset(dis, -1, sizeof dis);
dis[s] = 0;
std::queue<int> q;
q.push(s);
while(!q.empty())
{
int v = q.front();
q.pop();
if(v == t) return 1;
for(auto i : no[v])
{
int to = edge[i].to;
if(dis[to] == -1 && edge[i].flow < edge[i].cap)
dis[to] = dis[v] + 1, q.push(to);
}
}
return 0;
}
T dfs(int cur, T maxf)
{
if(maxf <= 0) return 0;
if(cur == t) return maxf;
for(;ptr[cur] < no[cur].size();ptr[cur]++)
{
int id = no[cur][ptr[cur]], to = edge[id].to;
if(dis[to] != dis[cur] + 1) continue;
T pushed = dfs(to, std::min(maxf, edge[id].cap - edge[id].flow) );
if(pushed)
{
edge[id].flow += pushed;
edge[id ^ 1].flow -= pushed;
return pushed;
}
}
return 0;
}
T dinic()
{
T Ans = 0, val;
while(bfs())
{
memset(ptr, 0, sizeof ptr);
while(val = dfs(s, inf) )
Ans += val;
}
return Ans;
}
};
int n, m;
Flow<i64> f;
std::map<int, int> mp;
signed main()
{
#ifdef ONLINE_JUDGE
ioclear;
#endif
std::cin >> n >> m;
int S = 0, T = 2 * n + m;
f.set(n, m, S, T);
for(int i = 1;i <= 2 * n;i++)
{
i64 c, d, e;
std::cin >> c >> d >> e;
f.add(S, i, c);
f.add(i, T, d);
f.add((i & 1) ? i + 1 : i - 1, i, e);
f.add(i, n + (i + 1) / 2, f.inf);
}
for(int i = 1;i <= m;i++)
{
i64 A, B, a, b;
std::cin >> A >> B >> a >> b;
int ida = n + (A + 1) / 2, idb = n + (B + 1) / 2;
f.add(ida, B, a);
f.add(A, idb, b);
}
std::cout << f.dinic();
}
详细
Test #1:
score: 0
Wrong Answer
time: 88ms
memory: 46132kb
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:
66518055494
result:
wrong answer 1st lines differ - expected: '22929674417', found: '66518055494'