HDU——1068 Girls and Boys
Girls and Boys
Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 12246 Accepted Submission(s): 5768
The input contains several data sets in text format. Each data set represents one set of subjects of the study, with the following description:
the number of students
the description of each student, in the following format
student_identifier:(number_of_romantic_relations) student_identifier1 student_identifier2 student_identifier3 ...
or
student_identifier:(0)
The student_identifier is an integer number between 0 and n-1, for n subjects.
For each given data set, the program should write to standard output a line containing the result.
0: (3) 4 5 6
1: (2) 4 6
2: (0)
3: (0)
4: (2) 0 1
5: (1) 0
6: (2) 0 1
3
0: (2) 1 2
1: (1) 0
2: (1) 0
2
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define N 1010
using namespace std;
bool vis[N];
int t,n,m,x,y,ans,girl[N],map[N][N];
int read()
{
,f=; char ch=getchar();
; ch=getchar();}
+ch-';ch=getchar();}
return x*f;
}
int find(int x)
{
;i<=n;i++)
{
if(!vis[i]&&map[x][i])
{
vis[i]=true;
||find(girl[i])) {girl[i]=x;;}
}
}
;
}
int main()
{
while(scanf("%d",&n)!=EOF)
{
ans=;
memset(map,,sizeof(map));
memset(girl,-,sizeof(girl));
;i<=n;i++)
{
x=read();m=read();
while(m--)
y=read(),map[x+][y+]=;
}
;i<=n;i++)
{
memset(vis,,sizeof(vis));
ans+=find(i);
}
printf(*n-ans)/);
}
;
}
HDU——1068 Girls and Boys的更多相关文章
- HDU 1068 Girls and Boys(最大独立集合 = 顶点数 - 最大匹配数)
HDU 1068 :题目链接 题意:一些男孩和女孩,给出一些人物关系,然后问能找到最多有多少个人都互不认识. 转换一下:就是大家都不认识的人,即最大独立集合 #include <iostream ...
- HDU 1068 Girls and Boys 二分图最大独立集(最大二分匹配)
Girls and Boys Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- hdu 1068 Girls and Boys (二分匹配)
Girls and Boys Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- hdu 1068 Girls and Boys(匈牙利算法求最大独立集)
Girls and Boys Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- hdu 1068 Girls and Boys (最大独立集)
Girls and BoysTime Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- HDU 1068 Girls and Boys (二分图最大独立集)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1068 有n个同学,格式ni:(m) n1 n2 n3表示同学ni有缘与n1,n2,n3成为情侣,求集合 ...
- [HDU] 1068 Girls and Boys(二分图最大匹配)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1068 本题求二分图最大独立点集.因为最大独立点集=顶点数-最大匹配数.所以转化为求最大匹配.因为没有给 ...
- hdu 1068 Girls and Boys 最大独立点集 二分匹配
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1068 思路: 求一集合满足,两两之间没有恋爱关系 思路: 最大独立点集=顶点数-最大匹配数 这里给出的 ...
- HDU 1068 Girls and Boys(模板——二分图最大匹配)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1068 Problem Description the second year of the univ ...
随机推荐
- js跨域请求的5中解决方式
跨域请求数据解决方案主要有如下解决方法: ? 1 2 3 4 5 JSONP方式 表单POST方式 服务器代理 Html5的XDomainRequest Flash request 分开说明: 一.J ...
- nodejs idea 创建项目 (一)
1.在工作空间创建module file->new module next next 项目的目录结构: bin:跟业务无关的公共部分 node_modules :默认的模块 public:公共模 ...
- php5.6.30开启redis扩展
注:5.6版本的php一定要下载phpredis3.0以上的版本,之前自己下载用的2.2.4的redis,安装配置完成后,PHP死活不支持redis的扩展,通过phpinfo打印也压根看不到,重复服务 ...
- 学习 微信小程序 大神不要笑
- DBUtils使用技巧
BbUtils(一) 结果集概览:http://www.cnblogs.com/myit/p/4269165.html DbUtils(二) 结果集实例:http://www.cnblogs.com/ ...
- 核武器代理CC工具V3.42最新版本!
软件说明 !!!有新版本更新,请移步到更新地址:https://www.cnblogs.com/cnhacker/p/10878688.html ########################### ...
- ansible配置mysql主从复制
配置主机1.下载安装所需安装包 [root@server1 ansible]# lsansible-2.7.8-1.el7.noarch.rpmansible-tower-setup-bundle-3 ...
- mysql5.7 this is incompatible with sql_mode=only_full_group_by错误
解决办法: https://blog.csdn.net/qq_42175986/article/details/82384160 前言: 一.原理层面 这个错误发生在mysql 5.7 版本及以上版本 ...
- 第3节 mapreduce高级:8、9、自定义分区实现分组求取top1
自定义GroupingComparator求取topN GroupingComparator是mapreduce当中reduce端的一个功能组件,主要的作用是决定哪些数据作为一组,调用一次reduce ...
- iOS工具】rvm、Ruby环境和CocoaPods安装使用及相关报错问题解决
〇.前言 <p>在iOS开发中 CocoaPods作为库依赖管理工具就是一把利器. 有了 CocoaPods则无需再通过拖 第三方库及第三方库所依赖的 framework静态库到项目中等麻 ...