using namespace std;
const LL MAXN = 9000001;
struct N
{
unsigned int v,next;
}edge[MAXN*2];
int head[MAXN];
int Top;
void Link(unsigned int u,unsigned int v)
{
edge[Top].v = v;
edge[Top].next = head[u];
head[u] = Top++;
}
void Init_head_Top(int n)
{
memset(head,-1,sizeof(unsigned int)*(n+2));
Top = 0;
}
int Match_Point[MAXN];
bool mark[MAXN];
bool dfs(int s)
{
for(int p = head[s] ; p != -1; p = edge[p].next)
{
if(mark[edge[p].v] == false)
{
mark[edge[p].v] = true;
if(Match_Point[edge[p].v] == -1 || dfs(Match_Point[edge[p].v]))
{
Match_Point[s] = edge[p].v;
Match_Point[edge[p].v] = s;
return true;
}
}
}
return false;
}
int Cal_Max_Match(int n)
{
int ans = 0;
for(int i = 1;i <= n; ++i)
{
if(Match_Point[i] == -1)
{
memset(mark,false,sizeof(bool)*(n+2));
if(dfs(i))
ans++;
}
}
return ans;
}
二分图匹配
最新推荐文章于 2022-04-22 20:35:43 发布