简单的最大二分图匹配
View Code
1 #include2 #include 3 using namespace std; 4 #include 5 #include 6 7 #define MAXN 505 8 9 int match[MAXN];10 int map[MAXN][MAXN];11 int vis[MAXN];12 int K,M,N; 13 14 int find(int x)15 {16 for(int i=1;i<=N;i++)17 { 18 if(map[x][i]&&!vis[i])19 {20 vis[i] = 1;21 if(!match[i] || find(match[i]))22 {23 match[i] = x;24 return 1;25 }26 }27 }28 return 0;29 } 30 31 int main()32 {33 while(scanf("%d",&K)!=EOF,K)34 {35 scanf("%d%d",&M,&N);36 memset(map,0,sizeof(map)); 37 memset(match,0,sizeof(match)); 38 int a,b;39 for(int i=0;i