hdu1068 Girls and Boys】的更多相关文章

题目:http://acm.hdu.edu.cn/showproblem.php?pid=1068 二分图的最大独立集数=节点数(n)— 最大匹配数(m) 另外需要注意的是: 本题求出的最大匹配数是实际的两倍需要m/2 #include<iostream> #include<stdio.h> #include<math.h> #include<string.h> #include<stdlib.h> using namespace std; ;…
题目链接: 二分匹配的应用 求最大独立集 最大独立集等于=顶点数-匹配数 本体中由于男孩和女孩的学号是不分开的,所以匹配数应是求得的匹配数/2 代码: #include<iostream> #include<cstdlib> #include<cstring> #include<cstdio> using namespace std; #define maxn 500 int g[maxn][maxn]; int vis_x[maxn]; int vis_y…
#include <cstdio> #include <algorithm> #include <cstring> #include <vector> using namespace std; ; vector<int>map[maxn]; bool mark[maxn]; int link[maxn]; int n; void init(){ ; i <= n; i++){ map[i].clear(); } memset(mark, f…
#include <cstdio> #include <cstring> #include <algorithm> #include <cstdlib> using namespace std; #define MAXN 500 int map[MAXN][MAXN]; int mark[MAXN]; int pipei[MAXN]; int n; int search(int a) { ; i < n; i++) { if (map[a][i] &a…
有一个集合男和一个集合女,给出两集合间一些一一相应关系.问该两集合中的最大独立集的点数. 最大独立集=顶点总数-最大匹配数 此题中.若(a,b)有关.则(b,a)有关.每个关系算了两次,相当于二分图的两边集合没有分男女.两边都是总人数. 所以此题中答案应该是 顶点总数-最大匹配数/2 #include<cstdio> #include<cstring> #include<cmath> #include<iostream> #include<algori…
Girls and Boys Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) [Problem Description] the second year of the university somebody started a study on the romantic relations between the students. The relation “romant…
Girls and Boys Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://poj.org/problem?id=1466 Description In the second year of the university somebody started a study on the romantic relations between the students. The relation "romantically involved&q…
Girls and Boys Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5565    Accepted Submission(s): 2481 Problem Descriptionthe second year of the university somebody started a study on the romanti…
Girls and Boys Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7577    Accepted Submission(s): 3472 Problem Description the second year of the university somebody started a study on the romant…
                                                            Girls and Boys Time Limit: 5000MS   Memory Limit: 10000K Total Submissions: 12192   Accepted: 5454 Description In the second year of the university somebody started a study on the romantic r…
http://poj.org/problem?id=1466 Girls and Boys Time Limit: 5000MS   Memory Limit: 10000K Total Submissions: 11085   Accepted: 4956 Description In the second year of the university somebody started a study on the romantic relations between the students…
Girls and Boys Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8470    Accepted Submission(s): 3890 Problem Description the second year of the university somebody started a study on the romant…
Girls and Boys Time Limit: 5000ms Memory Limit: 10000KB This problem will be judged on PKU. Original ID: 1466 64-bit integer IO format: %lld      Java class name: Main In the second year of the university somebody started a study on the romantic(浪漫的)…
Girls and Boys Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 9245    Accepted Submission(s): 4240 Problem Description the second year of the university somebody started a study on the romant…
解题报告 http://blog.csdn.net/juncoder/article/details/38160591 题目传送门(POJ) 题目传送门(HDU) 题意: 求满足条件的最大集合:集合内不论什么两个人都没有浪漫关系 思路: 跟POJ2771一样的题,变的简单多了.POJ2771解题报告 #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> us…
称号: Girls and Boys Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 189 Accepted Submission(s): 127   Problem Description the second year of the university somebody started a study on the romanti…
Girls and Boys Time Limit: 5000MS   Memory Limit: 10000K Total Submissions: 12747   Accepted: 5678 Description In the second year of the university somebody started a study on the romantic relations between the students. The relation "romantically in…
Girls and Boys Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://poj.org/problem?id=1466 Description In the second year of the university somebody started a study on the romantic relations between the students. The relation "romantically involved&q…
Girls and Boys Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6867    Accepted Submission(s): 3083 Problem Description the second year of the university somebody started a study on the romant…
Girls and Boys Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7044    Accepted Submission(s): 3178 Problem Description the second year of the university somebody started a study on the roman…
Girls and Boys Time Limit: 5000ms Memory Limit: 10000KB This problem will be judged on PKU. Original ID: 146664-bit integer IO format: %lld      Java class name: Main     In the second year of the university somebody started a study on the romantic r…
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 Problem Description the second year of the university somebody started a study on the roma…
Girls and Boys Time Limit: 5000MS   Memory Limit: 10000K Total Submissions: 10912   Accepted: 4887 Description In the second year of the university somebody started a study on the romantic relations between the students. The relation "romantically in…
Girls and BoysTime Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 13556    Accepted Submission(s): 6385 Problem Descriptionthe second year of the university somebody started a study on the romanti…
Girls and Boys Time Limit: 5000MS   Memory Limit: 10000K Total Submissions: 11097   Accepted: 4960 Description In the second year of the university somebody started a study on the romantic relations between the students. The relation "romantically in…
题意 有n个同学,给出同学之间的爱慕关系,选出一个集合使得集合中的人没有爱慕关系.问能选出的最大集合是多少. 分析 二分图的最大独立集. 最大独立集的意思是,在图中选出最多的点,使他们两两之间没有边,这个顶点的集合就是最大独立集. 先下结论:如果一个图是二分图,|最大独立集| = |V|-|最大匹配数|. 我们这么思考(设匹配数为\(v\)): 如果把二分图的最大匹配从原图中去掉,剩下的\(n-2v\)个顶点肯定是没有边相连的(如果还有边相连,我们可以一定可以再加入到匹配中,那还是个锤子的最大匹…
题目描述: 给出一系列男女配对意愿信息.求一个集合中的最大人数,满足这个集合中两两的人不能配对. /* 二分图的最大独立集 因为没有给出具体的男生和女生,所以可以将数据扩大一倍,即n个男生,n个女生, 根据定理,最大独立集=总数-匹配数(本题应该除以2) */ #include<cstdio> #include<iostream> #include<cstring> #define N 510 using namespace std; int a[N][N],used[…
最大点独立集就是无向图中最多的两两不相邻的点集. 二分图最大点独立集=顶点数-二分图最大边独立集(二分图最大匹配) 这一题男女分别作YX部,如果x和y有浪漫关系则连边,如此构造二分图,答案显然就是最大点独立集.另外要先进行二分图染色,以确定每个id的性别. #include<cstdio> #include<cstring> #include<queue> #include<algorithm> using namespace std; #define IN…
有n个人, 其中有男生和女生,接着有n行,分别给出了每一个人暗恋的对象(不止暗恋一个) 现在要从这n个人中找出一个最大集合,满足这个集合中的任意2个人,都没有暗恋这种关系. 输出集合的元素个数. 刚开始想,把人看成顶点,若有暗恋的关系,就连一条边,构成一个图 独立集的概念:一个图中两两互不相连的顶点集合 所以这道题,就是要求最大独立集 有:最大独立集+最小顶点覆盖=|V|(顶点的总个数) 那就求最小顶点覆盖了 根据题意: 暗恋的对象性别不同,所以a暗恋b,b暗恋c,c暗恋a这种关系不可能存在 也…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1068 有n个同学,格式ni:(m) n1 n2 n3表示同学ni有缘与n1,n2,n3成为情侣,求集合中不存在有缘成为情侣的同学的最大同学数. 独立集(图的顶点集的子集,其中任意两点不相邻) 二分图中 最大独立集 = 顶点个数 - 最大匹配数 因为男女不知道,将一个人拆成两个性别,求最大匹配后,除以2就行了. 这种做法比较难理解. #include <iostream> #include <…