#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 )
{
    
forint 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;
    
    
forint i= 0; i< n; ++i )
    
{
        memset( chk, 
falsesizeof(chk) );
        
        
if( dfs(i) ) res++;
    }

    
    
return res;
}


int main()
{
    
while( scanf("%d%d"&n,&m)!= EOF )
    
{
        memset( map, 
falsesizeof(map) );
        memset( match, 
-1sizeof(match) );
        
        
forint i= 0; i< n; ++i )
        
{
            
int t;
            scanf(
"%d"&t);
            
            
forint 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 阅读(110) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理