【二分图】 poj 1466
#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的更多相关文章
- poj 1466 Girls and Boys (最大独立集)
链接:poj 1466 题意:有n个学生,每一个学生都和一些人有关系,如今要你找出最大的人数.使得这些人之间没关系 思路:求最大独立集,最大独立集=点数-最大匹配数 分析:建图时应该是一边是男生的点, ...
- POJ 1466 Girls and Boys(二分图匹配)
[题目链接] http://poj.org/problem?id=1466 [题目大意] 给出一些人和他们所喜欢的人,两个人相互喜欢就能配成一对, 问最后没有配对的人的最少数量 [题解] 求最少数量, ...
- poj 1466 Girls and Boys(二分图的最大独立集)
http://poj.org/problem?id=1466 Girls and Boys Time Limit: 5000MS Memory Limit: 10000K Total Submis ...
- poj 1466 Girls and Boys 二分图的最大匹配
Girls and Boys Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://poj.org/problem?id=1466 Descripti ...
- POJ - 1466 Girls and Boys 二分图+最大独立集
标题效果:有着n学生,有一些同学之间的特殊关系.. .为了一探究竟m学生.要求m免两者之间的学生有没有这样的特殊关系 解决问题的思路:二分图的问题,殊关系是对称的.所以能够将两个点集都设置为n个点.求 ...
- Girls and Boys POJ - 1466 【(二分图最大独立集)】
Problem DescriptionIn the second year of the university somebody started a study on the romantic rel ...
- POJ 1466:Girls and Boys 二分图的最大点独立集
Girls and Boys Time Limit: 5000MS Memory Limit: 10000K Total Submissions: 11097 Accepted: 4960 D ...
- POJ 1466 Girls and Boys (匈牙利算法 最大独立集)
Girls and Boys Time Limit: 5000MS Memory Limit: 10000K Total Submissions: 10912 Accepted: 4887 D ...
- POJ 1466 Girls and Boys (ZOJ 1137 )最大独立点集
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=137 http://poj.org/problem?id=1466 题目大意: ...
随机推荐
- @NotNull vs @Column(nullable = false)
参考:Confusion: @NotNull vs @Column(nullable = false)
- CSS3的基础知识点
面临找工作之际,又将CSS3的基础知识撸了一把,做了相应的笔记,主要是方便自己查阅,参考的是W3C的知识. 1.CSS背景 (1).background-size 属性 background-s ...
- 后台验证url是不是有效的链接
/** * 判断链接是否有效 * 输入链接 * 返回true或者false */ public static boolean isValid(String strLink){ URL url=null ...
- MySQL(1) - 基础
参考资料: http://www.jianshu.com/p/91e3af27743f 一.MySQL介绍以及安装 1.1 MySQL介绍 MariaDB数据库管理系统是MySQL的一个分支,主要由开 ...
- Kettle jdbc连接hive出现问题
jdbc连接时报如下错误: Error connecting to database [k] : org.pentaho.di.core.exception.KettleDatabaseExcepti ...
- PHP中使用CURL(四)
为了安全,我们的web服务主机往往不能上网.维护的时候,也是通过跳板机,ssh登录后去操作.有时候我们的程序需要访问外网.比如需要调用外网其他程序的某个接口.这时可以通过PHP的CURL函数的CURL ...
- LeetCode OJ 162. Find Peak Element
A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ ...
- Excel教程(11) - 查找和引用函数
ADDRESS 用途:以文字形式返回对工作簿中某一单元格的引用. 语法: sheADDRESS(row_num,column_num,abs_num,a1,et_text) 参数:Row_num ...
- 洛谷-A+B Problem-洛谷的第一个任务
题目描述 Description 输入两个整数a,b,输出它们的和(a,b<=10^9) 输入输出格式 Input/output 输入格式:两个整数以空格分开输出格式:一个数 输入输出样例 ...
- Python 学习笔记3
人如果从来没有怀疑过自己,那他永远都不会进步. 今天学习Python解释器及其环境. http://www.pythondoc.com/pythontutorial3/interpreter.html