思路:很单纯的网络流,重点是卡时间 模板的高效性很重要啊该模板详解 参见这里
//4796MS
8836K
#include <stdio.h>
#include <string.h>
#define VM 100010
#define EM 400010
const int inf = 0x3f3f3f3f;
struct E
{
nxt, cap;
}edge[EM];
int head[VM],e,n,m,src,des;
int dep[VM], gap[VM];
void addedge(int cu, int cv, int cw)
{
= cu;
cv;
= cw;
= head[cu];
e++;
= cv;
cu;
= 0;
= head[cv];
e++;
}
int que[VM];
void BFS()
{
-1, sizeof(dep));
0, sizeof(gap));
1;
0, rear = 0;
0;
= des;
v;
!= rear)
que[front++];
front%VM;
i=head[u]; i!=-1; i=edge[i].nxt)
edge[i].to;
(edge[i].cap != 0 || dep[v] != -1)
continue;
= v;
% VM;
= dep[u] + 1];
}
int cur[VM],stack[VM];
int
Sap()
//sap模板
{
0;
0;
head, sizeof(head));
i;
(dep[src] < n)
des)
inf, inser = n;
i!=top; ++i)
> edge[stack[i]].cap)