Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
 User ID: Password:
Register

## 要从0开始吗?副代码好了!大家共乡!

Posted by chenxuan123456789 at 2012-08-10 14:21:42 on Problem 1274
```#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:
User ID:
Password:
Title:

Content:

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator