#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define N 210
bool map[N][N];
int chk[N];
int match[N];
int m,n;
int dfs( int p )
{
for( int i= 0; i< m; ++i )
if( map[p][i] && !chk[i] )
{
chk[i]= 1;
int t= match[i];
match[i]= p;
if( t== -1 || dfs(t) ) return 1;
match[i]= t;
}
return 0;
}
int Match()
{
int res= 0;
for( int i= 0; i< n; ++i )
{
memset( chk, false, sizeof(chk) );
if( dfs(i) ) res++;
}
return res;
}
int main()
{
while( scanf("%d%d", &n,&m)!= EOF )
{
memset( map, false, sizeof(map) );
memset( match, -1, sizeof(match) );
for( int i= 0; i< n; ++i )
{
int t;
scanf("%d", &t);
for( int j= 0; j< t; ++j )
{
int d;
scanf("%d",&d);
map[i][d-1]= true;
}
}
printf("%d\n", Match() );
}
return 0;
}
posted on 2008-11-04 18:55
Darren 阅读(118)
评论(0) 编辑 收藏 引用