#include<iostream>
#include<vector>
const int maxn=100010;
int match[maxn];
bool used[maxn];
bool dfs(int v){
used[v]=true;
for(int i=0;i<G[v].size();i++){
int u=G[u][i];
int w=match[u];
if(w<0||!used[w]&&dfs(w)){
match[u]=w;
match[w]=u;
return true;
}
}
return false;
}
int bipartite_matching(){
int res=0;
memset(match, -1, sizeof(match));
for(int v=0;v<V;i++){
if(match(v)<0){
memset(used, 0, sizeof(used));
if(dfs(v))
res++;
}
}
return res;
}
算法入门 28.二分图(容量为1)
最新推荐文章于 2025-12-29 10:54:39 发布

929

被折叠的 条评论
为什么被折叠?



