#include<bits/stdc++.h>
using namespace std;
int m,n,e,cnt,ans,flg[1000010],match[1000010],head[1000010];
struct node{
int w,nxt,v;
}edge[6000010];
void add(int u,int v)
{
edge[++cnt].v=v;
edge[cnt].nxt=head[u];
head[u]=cnt;
}
bool check(int u)
{
for(int i=head[u];i!=0;i=edge[i].nxt)
{
int v=edge[i].v;
if(flg[v]==false)
{
flg[v]=true;
if(match[v]==0||check(match[v])==true)
{
match[v]=u;
return true;
}
}
}
return false;
}
void solve()
{
for(int i=1;i<=n;i++)
{
memset(flg,false,sizeof(flg));
if(check(i)==true) ans++;
}
}
int main()
{
memset(head,-1,sizeof(head));
cin>>m>>n>>e;
for(int i=1;i<=e;i++)
{
int u,v;
cin>>u>>v;
if(u>n||v>m||u>m||v>n) continue;
add(u,v);
}
solve();
cout<<ans;
return 0;
}
前两个点A了 后几个点ans大了1
不明白哪里错了