标签:des style blog http color java os io
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)
Total Submission(s): 935 Accepted Submission(s): 523
1 #include<cstring> 2 #include<cstdio> 3 #include<cstdlib> 4 using namespace std; 5 int const maxn=102; 6 int n,m; 7 bool mat[maxn][maxn]; 8 bool vis[maxn]; 9 int mac[maxn]; 10 bool match(int x) 11 { 12 for(int i=1;i<=n;i++) 13 { 14 if(mat[x][i]&&!vis[i]){ 15 vis[i]=1; 16 if(!mac[i]||match(mac[i])){ 17 mac[i]=x; 18 return 1; 19 } 20 } 21 } 22 return 0; 23 } 24 int main(){ 25 int a,b; 26 //freopen("test.in","r",stdin); 27 while(scanf("%d%d",&n,&m)!=EOF){ 28 memset(mat,0,sizeof(mat)); 29 memset(mac,0,sizeof(mac)); 30 for(int i=1;i<=m;i++){ 31 scanf("%d",&a); 32 while(a--){ 33 scanf("%d",&b); 34 mat[i][b]=1; 35 } 36 } 37 38 int ans=0; 39 for(int i=1;i<=m;i++){ 40 memset(vis,0,sizeof(vis)); 41 if(match(i))ans++; 42 } 43 printf("%d\n",ans); 44 } 45 return 0; 46 }
hdu-----(1179)Ollivanders: Makers of Fine Wands since 382 BC.(二分匹配),布布扣,bubuko.com
hdu-----(1179)Ollivanders: Makers of Fine Wands since 382 BC.(二分匹配)
标签:des style blog http color java os io
原文地址:http://www.cnblogs.com/gongxijun/p/3928275.html