HDU——T 1068 Girls and Boys
http://acm.hdu.edu.cn/showproblem.php?pid=1068
Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 12257    Accepted Submission(s): 5775
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 <cstring>
#include <cstdio> using namespace std; const int N();
int n,match[N];
bool map[N][N],vis[N]; bool find(int u)
{
for(int v=;v<n;v++)
if(map[u][v]&&!vis[v])
{
vis[v]=;
if(!match[v]||find(match[v]))
{
match[v]=u;
return true;
}
}
return false;
} inline void read(int &x)
{
x=; register char ch=getchar();
for(;ch>''||ch<'';) ch=getchar();
for(;ch>=''&&ch<='';ch=getchar()) x=x*+ch-'';
} int AC()
{
for(int ans=;~scanf("%d",&n);ans=)
{
for(int v,u,q,i=;i<n;i++)
{
read(u);
for(read(q);q--;)
read(v),map[u][v]=;
}
for(int i=;i<n;i++)
{
if(find(i)) ans++;
memset(vis,,sizeof(vis));
}
printf("%d\n",n-ans/);
memset(map,,sizeof(map));
memset(match,,sizeof(match));
}
return ;
} int I_want_AC=AC();
int main(){;}
HDU——T 1068 Girls and Boys的更多相关文章
- 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 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 ...
 - hdoj 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 (二分图最大独立集)
		
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1068 有n个同学,格式ni:(m) n1 n2 n3表示同学ni有缘与n1,n2,n3成为情侣,求集合 ...
 - HDU 1068 Girls and Boys(最大独立集合 = 顶点数 - 最大匹配数)
		
HDU 1068 :题目链接 题意:一些男孩和女孩,给出一些人物关系,然后问能找到最多有多少个人都互不认识. 转换一下:就是大家都不认识的人,即最大独立集合 #include <iostream ...
 - [HDU] 1068 Girls and Boys(二分图最大匹配)
		
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1068 本题求二分图最大独立点集.因为最大独立点集=顶点数-最大匹配数.所以转化为求最大匹配.因为没有给 ...
 
随机推荐
- [剑指offer] 1. 二维数组中的查找 (数组)
			
注意是有序数组!! 思路: 1.利用二维数组由上到下,由左到右递增的规律,选取右上角或者左下角的元素a[m][n]与target进行比较, 当target小于元素a[m][n]时,那么target必定 ...
 - 调整mysql数据库最大连接数
			
1.查看mariadb数据库最大连接数,默认为151 MariaDB [(none)]> show variables like 'max_connections'; +------------ ...
 - shell 的变量
			
一.自定义变量 1.字母或者下划线开头,由字母.数字.下划线组成,大小写敏感,在使用变量时,要在变量前加上前缀 $,一般变量由大写字母表示,并且英文开头,"=" 两边应没有空格.如 ...
 - ASP.NET-后台cookie与前台JQUERY解析cookie
			
在controller中给cookie赋值 HttpCookie cookie =newHttpCookie("pageInfo"); cookie["page_inde ...
 - 基于ORA-12170 TNS 连接超时解决办法详解
			
转自原文 基于ORA-12170 TNS 连接超时解决办法详解 1.开始----程序-----Oracle------配置和移植工具-----Net Manager----本地----服务命名---o ...
 - [Hyperapp] Render Text with JSX in Hyperapp
			
Hyperapp is an ultra lightweight (1kb), minimal, functional, JavaScript library for building UIs. It ...
 - 编写html经常使用而又easy忘记的语句
			
设置文件字符编码: <meta charset="utf-8"> 内部样式表: <style type="text/css"> hr { ...
 - Picking up Jewels
			
Picking up Jewels There is a maze that has one entrance and one exit. Jewels are placed in passages ...
 - SEO分享:关于SEO的十个问题
			
想写的幽默一点,幽默细胞太少,想写的专业一点,又不够专业,结果就出现了这篇不伦不类的怪文,望海涵! 导读:前面写过一篇类似的文章,受到的评价好坏都有吧.有人说讲的没有实质性的内容,有些人抱怨回答的太过 ...
 - sql两个字段相加减,第三个字段没有值的原因.
			
错误的写法:(in_story_num-out_story_num) as story_num 正确的写法:(nvl(in_story_num,0)-nvl(out_story_num,0)) as ...