裸题。。。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<stdio.h>
#include<string.h>
bool map[109][109];
int mark[109];
bool flag[109];
int m;
bool dfs(int x)
{
int i;
for(i=1;i<=m;i++)
{
if(map[x][i]==0||flag[i]) continue;
flag[i]=1;
if(mark[i]==0||dfs(mark[i]))
{
mark[i]=x;
return 1;
}
}
return 0;
}
int main()
{
int i,g,k,j;
int count;
while(scanf("%d",&g),g)
{
scanf("%d%d",&m,&k);
memset(map,0,sizeof(map));
memset(mark,0,sizeof(mark));
count=0;
for(i=1;i<=k;i++)
{
int x,y;
scanf("%*d%d%d",&x,&y);
map[x][y]=1;
}
for(i=1;i<=g;i++)
{
memset(flag,0,sizeof(flag));
if(dfs(i)==1) count++;
}
printf("%d\n",count);
}
}