#include <iostream>
using namespace std;
#define N 301
#define M 96
bool map[N][M];
int match[M];
bool chk[M];
int n, m=85;
int dfs(int p)
{
int i,t;
for(i=1; i<=m; i++)
{
if(!chk[i] && map[p][i] )
{
chk[i]=1;
t=match[i];
match[i]=p;
if(t == -1 || dfs(t) ) return 1;
match[i]=t;
}
}
return 0;
}
int maxMah()
{
int i, ans=0;
for(i=1; i<=n; i++)
{
memset(chk, 0, sizeof(chk));
if(dfs(i)) ans++;
}
return ans;
}
int main()
{
int i,j,p,q,t;
while(scanf("%d", &n)!=EOF)
{
//printf("%d\n",n);
memset(map,0, sizeof(map));
memset(match, -1, sizeof(match));
for(i=1; i<=n; i++)
{
//printf("%d\n",i);
scanf("%d", &t);
//printf("%d\n", t);
for(j=0; j<t; j++)
{
scanf("%d%d",&p, &q);
map[i][(p-1)*12+q]=1;
}
}
printf("%d\n",maxMah());
}
return 0;
}
posted on 2010-03-25 16:26
wyiu 阅读(361)
评论(0) 编辑 收藏 引用 所属分类:
POJ