标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6701 Accepted Submission(s): 3358
#include<stdio.h> #include<string.h> #define MAX 1100 int map[MAX][MAX],vis[MAX],mode[MAX]; int t,n,m; int find(int x) { int i,j; for(i=0;i<m;i++) { if(map[x][i]&&vis[i]==0) { vis[i]=1; if(mode[i]==0||find(mode[i])) { mode[i]=x; return 1; } } } return 0; } int main() { int j,i,s,k; int x,y; while(scanf("%d",&n),n) { memset(map,0,sizeof(map)); memset(mode,0,sizeof(mode)); scanf("%d%d",&m,&k); while(k--) { scanf("%d%d%d",&t,&x,&y); if(x&&y) map[x][y]=1; } s=0; for(i=0;i<n;i++) { memset(vis,0,sizeof(vis)); if(find(i)) s++; } printf("%d\n",s); } return 0; }
hdoj 1150 Machine Schedule【匈牙利算法+最小顶点覆盖】
标签:
原文地址:http://www.cnblogs.com/tonghao/p/4662745.html