QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#91200 | #3249. 分组作业 | INFiNiTE_ENERZY | WA | 44ms | 14644kb | C++14 | 3.2kb | 2023-03-27 17:23:28 | 2023-03-27 17:23:31 |
Judging History
answer
//P8215
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e6 + 10, M = 1e6 + 10;
const long long inf = 1e17;
int n, m, Head[N], Edge[M], Leng[M], Next[M], tot = 1;
int dep[N], now[N];
void add(int u, int v, int w){
Edge[++tot] = v, Leng[tot] = w, Next[tot] = Head[u], Head[u] = tot;
Edge[++tot] = u, Leng[tot] = 0, Next[tot] = Head[v], Head[v] = tot;
}
bool bfs(int s, int t){
queue<int> q;
memset(dep, 0, sizeof(dep));
q.push(s);
dep[s] = 1;
now[s] = Head[s];
while(!q.empty()){
int u = q.front();
q.pop();
for(int i = Head[u]; i; i = Next[i]){
int v = Edge[i], w = Leng[i];
if(w && !dep[v]){
q.push(v);
now[v] = Head[v];
dep[v] = dep[u] + 1;
if(v == t){
return true;
}
}
}
}
return false;
}
int dfs(int u, int t, int flow){
if(u == t){
return flow;
}
int rest = flow;
for(int i = now[u]; i && rest; i = Next[i]){
int v = Edge[i], w = Leng[i];
now[u] = i;
if(w && dep[v] == dep[u] + 1){
int k = dfs(v, t, min(rest, w));
if(!k){
dep[v] = 0;
}
Leng[i] -= k;
Leng[i^1] += k;
rest -= k;
}
}
return flow - rest;
}
long long Dinic(int s, int t){
long long MaxFlow = 0, tmp;
while(bfs(s, t)){
while(tmp = dfs(s, t, inf)){
MaxFlow += tmp;
}
}
return MaxFlow;
}
//int n, m, hd[N], eg[N], nx[N], tot = 1;
//int dep[N], now[N];
//long long ln[N];
//
//void add(int x, int y, long long z){
// eg[++tot] = y;
// ln[tot] = z;
// nx[tot] = hd[x];
// hd[x] = tot;
// eg[++tot] = x;
// ln[tot] = 0;
// nx[tot] = hd[y];
// hd[y] = tot;
//}
//bool bfs(int s, int t){
// memset(dep, 0, sizeof(dep));
// memcpy(now, hd, sizeof(hd));
// queue<int> q;
// q.push(s);
// dep[s] = 1;
// while(!q.empty()){
// int x = q.front();
// q.pop();
// for(int i = hd[x]; i; i = nx[i]){
// int y = eg[i];
// long long z = ln[i];
// if(!dep[y] && z > 0){
// dep[y] = dep[x] + 1;
// q.push(y);
// if(y == t){
// return true;
// }
// }
// }
// }
// return false;
//}
//long long dfs(int x, int t, long long flow){
// if(x == t){
// return flow;
// }
// long long rest = flow;
// for(int i = now[x]; i; i = nx[i]){
// int y = eg[i];
// long long z = ln[i];
// now[x] = i;
// if(z > 0 && dep[y] == dep[x] + 1){
// long long k = dfs(y, t, min(z, rest));
// if(!k){
// dep[y] = 0;
// }
// ln[i] -= k;
// ln[i^1] += k;
// rest -= k;
// }
// }
// return flow - rest;
//}
//long long dinic(int s, int t){
// long long mf = 0, tmp = 0;
// while(bfs(s, t)){
// while(tmp = dfs(s, t, inf)){
// mf += tmp;
// }
// }
// return mf;
//}
signed main(){
scanf("%lld%lld", &n, &m);
int s = 3 * n + 1, t = 3 * n + 2;
#define p(x) (n+n+ceil((x)/2.0))
for(int i = 1; i <= n + n; ++ i){
int c, d, e;
scanf("%lld%lld%lld", &c, &d, &e);
add(s, i, d);
add(i, t, c);
add(p(i), i, inf);
if(i & 1){
add(i, i+1, e);
} else {
add(i, i-1, e);
}
}
for(int i = 1; i <= m; ++ i){
int A, B, a, b;
scanf("%lld%lld%lld%lld", &A, &B, &a, &b);
add(B, p(A), a);
add(A, p(B), b);
}
printf("%lld\n", Dinic(s, t));
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 44ms
memory: 14644kb
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:
28301586632
result:
wrong answer 1st lines differ - expected: '22929674417', found: '28301586632'