#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int Max = 500;
int num;
int g[Max][Max];
int linker[Max];
bool used[Max];
bool dfs(int u){
int v;
for(v=0;v<num;v++)
{
if(g[u][v]&&!used[v]){
used[v]=true;
if(linker[v]==-1 || dfs(linker[v]))
{
linker[v]=u;
return true;
}
}
}
return false;
}
int hungary(){
int res=0;
int u;
memset(linker,-1,sizeof(linker));
for(u=0;u<num;u++){
memset(used,0,sizeof(used));
if(dfs(u)) res++;
}
return res;
}
int main()
{
int a,b,c;
int cases;
while(scanf("%d",&cases)!=EOF){
num=cases;
int m;
memset(g,0,sizeof(g));
while(cases--){
scanf("%d: (%d)",&a,&b);
for(int i=0;i<b;i++){
scanf("%d",&c);
g[a][c]=1;
}
}
printf("%d\n",num-hungary()/2);
}
}
hdu1068 Girls and Boys(二分图)
最新推荐文章于 2021-05-24 02:20:56 发布