题目
思路
板子能有啥思路
(Code)
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#define MAXN 1001
using namespace std;
int n,m,e;
int qwq[MAXN][MAXN],match[MAXN];
bool vis[MAXN];
inline int read(){
int x=0;bool f=0;char c=getchar();
while(c<'0'||c>'9'){if(c=='-')f=!f;c=getchar();}
while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
return f?-x:x;
}
bool go(int x){
for(int i=1;i<=m;++i){
if(!vis[i]&&qwq[x][i]){
vis[i]=1;
if(!match[i]||go(match[i])){
match[i]=x;
return 1;
}
}
}
return 0;
}
int main(){
n=read(),m=read(),e=read();
int u,v;
for(int i=1;i<=e;++i){
u=read(),v=read();
if(u>n||v>m) continue;
qwq[u][v]=1;
}
int ans=0;
for(int i=1;i<=n;++i){
memset(vis,0,sizeof(vis));
if(go(i)) ans++;
}
printf("%d
",ans);
return 0;
}