Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
要从0开始吗?副代码好了!大家共乡!#include <stdio.h> #include <string.h> #define M 210 int g[M][M]; int used[M]; int match[M]; int n,m; int dfs(int s) { int i; for(i=0;i<m;i++) { if(!used[i]&&g[s][i]) { used[i]=1; if(match[i]==-1||dfs(match[i])) { match[i]=s; return 1; } } } return 0; } int main() { int i,a,b,k,res,j; while(scanf("%d %d",&n,&m)!=EOF) { memset(g,0,sizeof(g)); memset(match,-1,sizeof(match)); for(i=0;i<n;i++) { scanf("%d",&k); for(j=0;j<k;j++) { scanf("%d",&b); g[i][b-1]=1; } } res=0; for(i=0;i<n;i++) { memset(used,0,sizeof(used)); if(dfs(i)) res++; } printf("%d\n",res); } return 1; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator