博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Girls and Boys
阅读量:5951 次
发布时间:2019-06-19

本文共 1803 字,大约阅读时间需要 6 分钟。

Girls and Boys

Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 249 Accepted Submission(s): 163
 
Problem Description
the second year of the university somebody started a study on the romantic relations between the students. The relation “romantically involved” is defined between one girl and one boy. For the study reasons it is necessary to find out the maximum set satisfying the condition: there are no two students in the set who have been “romantically involved”. The result of the program is the number of students in such a set.
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.
 
 
Output
            
 
Sample Input
70: (3) 4 5 61: (2) 4 62: (0)3: (0)4: (2) 0 15: (1) 06: (2) 0 130: (2) 1 21: (1) 02: (1) 0
 
Sample Output
52
 
 
Source
Southeastern Europe 2000
 
Recommend
JGShining
 
/*初次思考:给出你一个点阵,然后让你求最大连通图的点数并查集想法,找点#错误:题意没理解明白题意:找出一个最大集合使得任意两个人没有关系因为有关系的肯定是男女(暂时不考虑性取向的问题)所以就将整个关系图,联系到了二分图上,进而用到二分匹配问题的解决方案用到“匈牙利算法”要求最大的没有关系的集合,就是总顶点数-最大匹配数*/#include
using namespace std;int n,u,m,v;/***********************二分匹配模板**************************/const int MAXN=1010;int g[MAXN][MAXN];//编号是0~n-1的 int linker[MAXN];//记录匹配点i的匹配点是谁bool used[MAXN];bool dfs(int u)//回溯看能不能通过分手来进行匹配{ int v; for(v=0;v

 

转载于:https://www.cnblogs.com/wuwangchuxin0924/p/6198420.html

你可能感兴趣的文章
access_token is invalid or not latest hint
查看>>
H3C设备之 EASY NAT
查看>>
Linux常用命令参考手册02
查看>>
linux 编写shell管理脚本01。2
查看>>
Emmet 文档下载,所有快捷键总结
查看>>
通过EmbeddedServletContainerCustomizer接口调优Tomcat
查看>>
hdu2000——ASCII码排序
查看>>
spring配置线程池
查看>>
Ubuntu 16.04 安裝chrome
查看>>
开发了个 Flipper 调试工具的 Flutter 版本 SDK,让 Flutter 应用调试起来更容易
查看>>
08.实例方法和类方法的区别与及工厂方法
查看>>
mysql 备份
查看>>
内核编译
查看>>
继承和泛型
查看>>
exchange2010 取消OWA内更改密码选项
查看>>
Reverse digits of an integer.
查看>>
openresty 安装
查看>>
2014年前端开发者如何提升自己
查看>>
Web前端工程师应该掌握的内容有哪些
查看>>
软件公司多注重开发不注重管理
查看>>