#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
#define MAX 1001
int Map[MAX][MAX];//图
int link[MAX];//匹配
int vis[MAX];//标记
int m;
int dfs(int x){
for(int i = 0;i < m;i++){
if(Map[x][i] && vis[i] == 0){
vis[i] = 1;
if(link[i] == -1 || dfs(link[i])){
link[i] = x;
return 1;
}
}
}
return 0;
}
int main(){
int k,stu,num;
char a,b,c;
while(~scanf("%d",&m)){
memset(Map,0,sizeof(Map));
memset(link,-1,sizeof(link));
for(int i = 0;i < m;i++){
scanf("%d: (%d)",&num,&k);
for(int j = 0;j < k;j++){
scanf("%d",&stu);
Map[num][stu] = 1;
}
}
/*for(int i = 0;i < m;i++){
for(int j = 0;j < m;j++)
cout<<Map[i][j];
cout<<endl;
}*/
int ans = 0;
for(int i = 0;i < m;i++){
memset(vis,0,sizeof(vis));
if(dfs(i)) ans++;
}
printf("%d\n",m - ans / 2);
}
return 0;
}
POJ 1466 Girls and Boys
最新推荐文章于 2017-07-21 15:11:26 发布