描述 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…
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 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…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1068 有n个同学,格式ni:(m) n1 n2 n3表示同学ni有缘与n1,n2,n3成为情侣,求集合中不存在有缘成为情侣的同学的最大同学数. 独立集(图的顶点集的子集,其中任意两点不相邻) 二分图中 最大独立集 = 顶点个数 - 最大匹配数 因为男女不知道,将一个人拆成两个性别,求最大匹配后,除以2就行了. 这种做法比较难理解. #include <iostream> #include <…
链接:poj 1466 题意:有n个学生,每一个学生都和一些人有关系,如今要你找出最大的人数.使得这些人之间没关系 思路:求最大独立集,最大独立集=点数-最大匹配数 分析:建图时应该是一边是男生的点,一边是女生的点连边.可是题目中没说性别的问题.仅仅能将每一个点拆成两个点.一个当作是男的点,一个当作是女的点了,然后连边.因为关系是相互的.这样就造成了边的反复.也就是边集是刚才的二倍,从而导致了最大匹配变成了原本的二倍.因此,此时最大独立集=点数-最大匹配数/2. #include<stdio.h…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1068 题目大意:有n个人,一些人认识另外一些人,选取一个集合,使得集合里的每个人都互相不认识,求该集合中人的最大个数. 解题思路:这题就是求最大独立集,但是这并不是两个集合,而是一个集合,所以求出最大匹配后需要/2,然后代公式:最大独立集=N-最大匹配. 代码: #include<iostream> #include<cstdio> #include<cstring> #i…
http://acm.hdu.edu.cn/showproblem.php?pid=1068 因为没有指定性别,所以要拆点,把i拆分i和i’ 那么U=V-M (M是最大匹配,U最大独立集,V是顶点数) 2U=2V-2M  所以 U=n-M'/2. (没怎么看明白)  但是不这样会wa. #include <iostream> #include <cstdio> #include <cmath> #include <vector> #include <c…
#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…
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: 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…