#include <iostream>
#include <memory.h>
#include <cstdio>
using namespace std;
int c;
const int maxn=;
int visit[maxn],map[maxn][maxn],link[maxn];
bool DFS(int a)
{
for(int i=;i<c;i++)
{
if(!visit[i] && map[a][i])
{
visit[i]=;
if(link[i]==- || DFS(link[i]))
{
link[i]=a;
return true;
}
}
}
return false;
}
int main()
{
// freopen("in.txt","r",stdin);
int x,y,tmp;
while(cin >> c)
{
memset(map,,sizeof(map));
memset(link,-,sizeof(link));
for(int i=;i<c;i++)
{
scanf("%d: (%d)",&x,&y);
for(int j=;j<y;j++)
{
scanf("%d",&tmp);
map[i][tmp]=;
}
}
int sum=;
for(int i=;i<c;i++)
{
memset(visit,,sizeof(visit));
if(DFS(i))sum++;
}
cout << c-sum/ <<endl;
}
return ;
}

【二分图】 poj 1466的更多相关文章

  1. poj 1466 Girls and Boys (最大独立集)

    链接:poj 1466 题意:有n个学生,每一个学生都和一些人有关系,如今要你找出最大的人数.使得这些人之间没关系 思路:求最大独立集,最大独立集=点数-最大匹配数 分析:建图时应该是一边是男生的点, ...

  2. POJ 1466 Girls and Boys(二分图匹配)

    [题目链接] http://poj.org/problem?id=1466 [题目大意] 给出一些人和他们所喜欢的人,两个人相互喜欢就能配成一对, 问最后没有配对的人的最少数量 [题解] 求最少数量, ...

  3. poj 1466 Girls and Boys(二分图的最大独立集)

    http://poj.org/problem?id=1466 Girls and Boys Time Limit: 5000MS   Memory Limit: 10000K Total Submis ...

  4. poj 1466 Girls and Boys 二分图的最大匹配

    Girls and Boys Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://poj.org/problem?id=1466 Descripti ...

  5. POJ - 1466 Girls and Boys 二分图+最大独立集

    标题效果:有着n学生,有一些同学之间的特殊关系.. .为了一探究竟m学生.要求m免两者之间的学生有没有这样的特殊关系 解决问题的思路:二分图的问题,殊关系是对称的.所以能够将两个点集都设置为n个点.求 ...

  6. Girls and Boys POJ - 1466 【(二分图最大独立集)】

    Problem DescriptionIn the second year of the university somebody started a study on the romantic rel ...

  7. POJ 1466:Girls and Boys 二分图的最大点独立集

    Girls and Boys Time Limit: 5000MS   Memory Limit: 10000K Total Submissions: 11097   Accepted: 4960 D ...

  8. POJ 1466 Girls and Boys (匈牙利算法 最大独立集)

    Girls and Boys Time Limit: 5000MS   Memory Limit: 10000K Total Submissions: 10912   Accepted: 4887 D ...

  9. POJ 1466 Girls and Boys (ZOJ 1137 )最大独立点集

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=137 http://poj.org/problem?id=1466 题目大意: ...

随机推荐

  1. 《JavaScript网页特效经典300例-高级篇》

    <Javascript网页经典特性300例> 高级篇 第18章:ajax应用 Ajax传输JSON数据实例定义一套自己的Ajax框架 第19章:面向对象的特性 定义一个类利用prototy ...

  2. HDU2124 Repair the Wall(贪心)

    Problem Description Long time ago , Kitty lived in a small village. The air was fresh and the scener ...

  3. Node.js:常用工具util

    概要:本篇博客的主要内容是介绍node.js的常用工具util. 1.util.inherits util.inherits(constructor,superConstructor)是一个实现对象间 ...

  4. 安装mcrouter

    下载准备: mcrouter 下载地址 : https://github.com/facebook/mcrouter gflags 下载地址:http://download.csdn.net/deta ...

  5. HttpServletResponse应用----生成验证码

    1.1生成随机图片用作验证码 生成图片主要用到BufferedImage类 package gacl.response.study;import java.awt.Color;import java. ...

  6. uilabel 复制

    //添加一个长按响应方法 - (void)addLongPressGestureRecognizer { UILongPressGestureRecognizer * longPress = [[UI ...

  7. 与导航栏下控件的frame相关的edgesForExtendedLayout、translucent、extendedLayoutIncludesOpaqueBars、automaticallyAdjustsScrollViewInsets等几个属性的详解

    在引入了导航控制器UINavigationController和分栏控制器UITabBarController之后,我们在设置控件的frame的时候就需要注意避开导航栏UINavigationBar ...

  8. ssl证书验证

    当我们在访问https网站时,浏览器就会自动下载该网站的SSL证书,并对证书的安全性进行检查. 其他概念不说了,有效期之类的验证也不说了.只说数字证书的真实性和可信性验证. 1.CA下发给网站的证书是 ...

  9. git 常用使用及问题记录

    1.打开bash,进入工程根目录(引用whaon的话:是和.classpath和.project同级的目录).PS:我的系统是win7,在bash切换到E的命令是 cd /e: 2.运行 git in ...

  10. python常用函数年初大总结

    1.常用内置函数:(不用import就可以直接使用) help(obj) 在线帮助, obj可是任何类型 callable(obj) 查看一个obj是不是可以像函数一样调用 repr(obj) 得到o ...