#include "stdio.h" // 二分匹配 hdu 2063 #include "string.h" #define N 1005 int n,m; bool mark[N]; int map[N][N],route[N]; int find(int a) //找增广路 { int i; for(i=1;i<=m;i++) { if(map[a][i]==1 && mark[i]==false) { mark[i] = 1; if(route[i]==0 || find(route[i])==1)//如果i没有匹配,直接跟a匹配,如果有匹配,找link[i]的增广路 { route[i] = a; return 1; } } } return 0; } int main() { int i,t,x,y,sum; while(scanf("%d",&t),t) { sum = 0; scanf("%d%d",&n,&m); memset(map,0,sizeof(map)); memset(route,0,sizeof(route)); for(i=1;i<=t;i++) { scanf("%d%d",&x,&y); map[x][y] = 1; } for(i=1;i<=n;i++) { memset(mark,false,sizeof(mark)); sum += find(i); } printf("%d ",sum); } return 0; }