匈牙利算法。复杂度为O(mn)。
对每个点都找以它为起点的增广路,当找到增广路后,匹配数必定加1。
#include <stdio.h>
#include <string.h>
const int N = 105;
const int M = 10005;
struct Vertex
{
int head;
}V[N];
struct Edge
{
int v,next;
}E[M];
int top,match[N];
bool used[N];
void Init()
{
top = 0;
memset(V,-1,sizeof(V));
}
void Add_Edge(int u,int v)
{
E[top].v = v;
E[top].next = V[u].head;
V[u].head = top++;
}
bool dfs(int u)
{
for(int i=V[u].......
阅读全文