HDU 2458 - Kindergarten
有一堆男孩和女孩,男孩和男孩之间,女孩和女孩之间互相认识,给出一堆男孩女孩之间认识的关系,
问一个组里最多多少人相互都认识
那么
二分图里
将不认识的连线
那么 相互认识的人最多 就为 最大独立点集
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int map[][];
int link[];
int vis[];
int n,m,k,ans;
bool dfs(int t)
{
int x;
for(int i=;i<=m;i++)
{
if(!vis[i]&&!map[t][i])
{
vis[i]=;
if(link[i]==-||dfs(link[i]))
{
link[i]=t;
return ;
}
}
}
return ;
}
int main()
{
int i,j,a,b,t=;
while(~scanf("%d%d%d",&n,&m,&k)&&(n+m+k))
{
memset(map,,sizeof(map));
for(i=;i<=k;++i)
{
scanf("%d%d",&a,&b);
map[a][b]=;
}
memset(link,-,sizeof(link));
ans=;
for(i=;i<=n;i++)
{
memset(vis,,sizeof(vis));
if(dfs(i)) ++ans;
}
ans=m+n-ans;
printf("Case %d: %d\n",++t,ans);
}
}
HDU 2458 - Kindergarten的更多相关文章
- hdu 3926 Hand in Hand 同构图
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3926 In order to get rid of Conan, Kaitou KID disguis ...
- hdu 4815 Little Tiger vs. Deep Monkey(01背包)
http://acm.hdu.edu.cn/showproblem.php?pid=4815 Description A crowd of little animals is visiting a m ...
- 【转载】图论 500题——主要为hdu/poj/zoj
转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并 ...
- HDU 3969 Hawk-and-Chicken(dfs+tarjan缩点优化,网上最详细解析!!!)
Hawk-and-Chicken Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- (KMP 水)Wow! Such Doge! -- hdu -- 4847
http://acm.hdu.edu.cn/showproblem.php?pid=4847 Wow! Such Doge! Time Limit:1000MS Memory Limit:32 ...
- HDU 5643 King's Game 打表
King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...
- hdu 3410 单调栈
http://acm.hdu.edu.cn/showproblem.php?pid=3410 Passing the Message Time Limit: 2000/1000 MS (Java/Ot ...
- hdu图论题目分类
=============================以下是最小生成树+并查集====================================== [HDU] 1213 How Many ...
- HDU 3639 Hawk-and-Chicken
Hawk-and-Chicken Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
随机推荐
- linux上备份Oracle时EXP-00091的错误解决方法
unix/linux上备份Oracle时EXP-00091的错误解决方法 unix/linux上备份数据时的错误解决方法 EXP-00091: Exporting questionable stati ...
- 0112.1——iOS开发之理解iOS中的MVC设计模式
模型-视图-控制器(Model-View-Controller,MVC)是Xerox PARC在20世纪80年代为编程语言Smalltalk-80发明的一种软件设计模式,至今已广泛应用于用户交互应用程 ...
- UICollectionView的简单使用和常用代理方法
UICollectionView相对于UITableView有更加自由的布局,做出的界面可变性更大最近开始接触使用UICollectionView,整理了一下常用的代理方法 首先需要先添加UIColl ...
- 编译错误“The run destination My Mac 64-bit is not valid for Running the scheme '***',解决办法
1. iOS APP Project or Mac APP Project编译错误提示: “The run destination My Mac 64-bit is not valid for Ru ...
- 简单的拖动手势控制侧拉view显示
通过 UIPanGestureRecognizer 手势来控制侧拉view的显示 在QHLViewController.m文件中,先添加一些宏定义和参数等等. #define QHLAnimatin ...
- UIView的一些常用属性和方法
UIView的一些常用属性和方法 1. UIView的属性 UIView继承自UIResponder,拥有touches方法. - (instancetype)initWithFrame:(CGRec ...
- Android SDK 更新时修改hosts文件仍然无法更新,可试试这个方法……
Android SDK 更新时修改hosts文件仍然无法更新,此时必定万分蛋疼.在hosts文件中更换了各种ip,仍然解决不了!!!!!!!!!!!!!!? 第一步: 打开此软件,等待服务器连接 第二 ...
- wordpress教程之the_author_meta()显示用户的信息
描述 模板标签函数the_author_meta可以显示用户数据.如果该函数在文章主循环(Loop)中,则不必指定作者的ID值,标签所显示的就是当前文章作者的内容.如果在主循环(Loop)外,则需要指 ...
- USB枚举过程的详细流程
USB枚举过程的详细流程 用户将一个USB设备插入USB端口,主机为端口供电,设备此时处于上电状态.主机检测设备.1>Hub使用中断通道将事件报告给Host.2>Host发送Get_Por ...
- C# 操作IE浏览器
最近的一个B/S系统中,用到了指模录入,当用户按了手指摸之后,要在IE浏览器的一个文本框上显示用户的姓名.由于要监控指模机的输入,因此客户端需要装一个.net控制台程序,通过此控制台程序监控指模机.这 ...