#include <iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define maxn 1000
using namespace std;
int nx,ny,match[maxn];
bool vis[maxn],w[maxn][maxn];
bool find(
int x){
for(
int i=
1;i<=ny;i++){
if(vis[i])
continue;
vis[i]=
true;
if(match[i]==-
1||find(match[i])){
match[i]=x;
return true;
}
}
return false;
}
int suan(){
int ans=
0;
memset(w,
0,
sizeof(w));
memset(match,-
1,
sizeof(match));
for(
int i=
1;i<=nx;i++){
memset(vis,
0,
sizeof(vis));
if(find(i)) ans++;
}
return ans;
}
int m,a,b;
int main(){
scanf(
"%d%d",&nx,&ny);
for(
int i=
1;i<=m;i++){
scanf(
"%d%d",&a,&b);
w[a][b]=
true;
}
int out=suan();
if(out)
printf(
"%d",out);
else puts(
"NO!!!!!");
return 0;
}
转载于:https://www.cnblogs.com/leotan0321/p/6081386.html