POJ 1466 最大独立集入门】的更多相关文章

题意:n个学生,给你每个学生浪漫的学生学号(男女之间浪漫),问你找出一个最大的集合保证集合内的任意两个学生之间没有相互浪漫关系,输出最大集合的人数. 注意:这里的浪漫边是双向的,如果1对2浪漫, 那么2对1也浪漫,题意好像没说清楚, 但我测了一下,是双向边. 思路:最大独立集和最小点覆盖集是互补的,所以 最大独立集 == 总人数n - 最小点覆盖集, 如果题目给你的是二分图那么直接二分匹配一下即可,但这题不是二分图,我们抓住双向边,那么我们进行拆点, 做一次匹配,求出来的匹配数是(左边男生匹配右…
#include<stdio.h> #include<string.h>//这个分开后男的站在一边女的站在一边,不肯能有les或者gay.最大独立集=n-最大匹配数 #define  N  510 int map[N][N],n,mark[N],link[N]; int find(int u) {  int i;  for(i=0;i<=n;i++)  if(!mark[i]&&map[u][i]) {     mark[i]=1;     if(link[i…
链接:poj 1466 题意:有n个学生,每一个学生都和一些人有关系,如今要你找出最大的人数.使得这些人之间没关系 思路:求最大独立集,最大独立集=点数-最大匹配数 分析:建图时应该是一边是男生的点,一边是女生的点连边.可是题目中没说性别的问题.仅仅能将每一个点拆成两个点.一个当作是男的点,一个当作是女的点了,然后连边.因为关系是相互的.这样就造成了边的反复.也就是边集是刚才的二倍,从而导致了最大匹配变成了原本的二倍.因此,此时最大独立集=点数-最大匹配数/2. #include<stdio.h…
题目链接:http://poj.org/problem?id=1466 Girls and Boys Time Limit: 5000MS   Memory Limit: 10000K Total Submissions: 12026   Accepted: 5355 Description In the second year of the university somebody started a study on the romantic relations between the stu…
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: 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…
有n个人, 其中有男生和女生,接着有n行,分别给出了每一个人暗恋的对象(不止暗恋一个) 现在要从这n个人中找出一个最大集合,满足这个集合中的任意2个人,都没有暗恋这种关系. 输出集合的元素个数. 刚开始想,把人看成顶点,若有暗恋的关系,就连一条边,构成一个图 独立集的概念:一个图中两两互不相连的顶点集合 所以这道题,就是要求最大独立集 有:最大独立集+最小顶点覆盖=|V|(顶点的总个数) 那就求最小顶点覆盖了 根据题意: 暗恋的对象性别不同,所以a暗恋b,b暗恋c,c暗恋a这种关系不可能存在 也…
Description In 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…
标题效果:有着n学生,有一些同学之间的特殊关系.. .为了一探究竟m学生.要求m免两者之间的学生有没有这样的特殊关系 解决问题的思路:二分图的问题,殊关系是对称的.所以能够将两个点集都设置为n个点.求出最大匹配后再除以2就可以得到(由于关系是对称的.所以所求得的最大匹配是双倍的) 得到最大匹配了,能够由定理得到 最大独立集 = n - 最大匹配数 #include<cstdio> #include<vector> #include<cstring> using name…
Problem DescriptionIn 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…