这是一份题解
2024-05-25 19:54:45
发布于:广东
20阅读
0回复
0点赞
#include<bits/stdc++.h>
#include<vector>
using namespace std;
const int N=505;
vector<int>edge[N];
int match[N];
bool vis[N];
bool dfs(int u){
for(int i=0;i<edge[u].size();i++){
int v=edge[u][i];
if(!vis[v]){
vis[v]=true;
if(match[v]==-1||dfs(match[v])){
match[v]=u;
return true;
}
}
}
return false;
}
int maxMatch(int n,int m){
memset(match,-1,sizeof(match));
int maxMatch=0;
for(int i=1;i<=n;i++){
memset(vis,false,sizeof(vis));
if(dfs(i)){
++maxMatch;
}
}
return maxMatch;
}
int main(){
int n,m,e;
cin>>n>>m>>e;
for(int i=0;i<e;i++)
{
int u,v;
cin>>u>>v;
edge[u].push_back(v);
}
cout<<maxMatch(n,m)<<endl;
}
全部评论 4
2024-08-09 来自 广东
0https://www.acgo.cn/application/1821812545799495680
2024-08-09 来自 广东
0CODM是什么
2024-08-09 来自 广东
0我不信你不知道
2024-08-09 来自 广东
0真的不知道
2024-08-09 来自 广东
0
你是不是玩codm
2024-08-09 来自 广东
0
有帮助,赞一个