思路:最大匹配 也是很裸的一道题….
// by SiriusRen
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 500
int n,tot=0,first[N],v[N*N],next[N*N],jy,xx,yy,ans=0,vis[N],fa[N];
void add(int x,int y){v[tot]=y,next[tot]=first[x],first[x]=tot++;}
bool dfs(int x){
for(int i=first[x];~i;i=next[i])
if(!vis[v[i]]){
vis[v[i]]=1;
if(!fa[v[i]]||dfs(fa[v[i]])){
fa[v[i]]=x;return 1;
}
}
return 0;
}
int main()
{
while(~scanf("%d",&n)){
memset(first,-1,sizeof(first));
memset(fa,0,sizeof(fa)),tot=ans=0;
for(int i=1;i<=n;i++){
scanf("%d",&jy);
while(jy--)
scanf("%d%d",&xx,&yy),add(i,xx*12+yy+305);
}
for(int i=1;i<=n;i++,memset(vis,0,sizeof(vis)))if(dfs(i))ans++;
printf("%d
",ans);
}
}