POJ 3692 最大独立集】的更多相关文章

题意:有G个女生,B个男生,所有的女生都互相认识,所有的男生都互相认识,还有N对男女,他们互相认识. 问从中选出最多的人数,是的他们全部互相认识. 思路:这道题的构图很巧妙,对于他的补图构图,对于所有互相认识的人,我们置Map[i][j] = 0 ,那么不认识的人置为1. 因为最大独立集中所有的点相互都没有边,即他们之间互相都认识,所以这道题就转化成了求最大独立集. 最大独立集=点数-最大匹配. CODE: #include <set> #include <map> #includ…
[题目链接] http://poj.org/problem?id=3692 [题目大意] 男生相互之间都认识,女生相互之间也都认识, 一些男生和一些女生相互之间也认识,求找出最多的人参加派对, 他们相互之间都认识 [题解] 我们建认识图的反图,将相互之间不认识的连线, 那么问题转化为求这个图的最大独立集, 最大独立集答案为总点数减去最大匹配. [代码] #include <cstdio> #include <cstring> using namespace std; const i…
Kindergarten Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 4903   Accepted: 2387 Description In a kindergarten, there are a lot of kids. All girls of the kids know each other and all boys also know each other. In addition to that, some…
Description In a kindergarten, there are a lot of kids. All girls of the kids know each other and all boys also know each other. In addition to that, some girls and boys know each other. Now the teachers want to pick some kids to play a game, which n…
题意: 有G个女孩,B个男孩.女孩彼此互相认识,男孩也彼此互相认识.有M对男孩和女孩是认识的.分别是(g1,b1),.....(gm,bm). 现在老师要在这G+B个小孩中挑出一些人,条件是这些人都互相认识.问最多可以挑出多少人. 思路: 女孩之间互相认识,男孩之间互相认识,所以我们可以将连边定义为:不认识.即:若两个节点之间有连边,则两个节点互不认识. 故题意即为选出最多的点使得这些点任意两点之间没有连边.即选最少的点覆盖所有边.(二分图最大独立集/二分图最小点覆盖) 代码: vector<i…
Kindergarten Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 5660   Accepted: 2756 Description In a kindergarten, there are a lot of kids. All girls of the kids know each other and all boys also know each other. In addition to that, some…
题目链接:http://poj.org/problem?id=3692 Description In a kindergarten, there are a lot of kids. All girls of the kids know each other and all boys also know each other. In addition to that, some girls and boys know each other. Now the teachers want to pi…
id=3692">Kindergarten Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 4920   Accepted: 2399 Description In a kindergarten, there are a lot of kids. All girls of the kids know each other and all boys also know each other. In addition t…
Kindergarten Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 4787   Accepted: 2326 Description In a kindergarten, there are a lot of kids. All girls of the kids know each other and all boys also know each other. In addition to that, some…
思路: 如果我们将认识的建边,求最大独立集就是互相不认识的人数.那么我们反过来,将不认识的建图,求最大独立集就是互相认识的人数. #include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #define Maxn 210 int graphic[Maxn][Maxn],vi[Maxn],match[Maxn],n,m; int dfs(int u) { int i; ;…
这道题又无耻的抄袭了别人的代码. 刚开始以为是最大匹配,把条件不相符的人连一起,然后求最大匹配,感觉麻烦,然后看了别人的解题报告,是把相符的人连一起,然后减去,其实就是最大独立集. 最大独立集=|G|-最大匹配. 首先先把性别分开,因为同性不能成为couple,然后把符合条件的异性连一起,然后就是最大匹配了. #include<stdio.h> #include<string.h> #define maxn 505 #define maxl 106 struct Person {…
题意:n个学生,给你每个学生浪漫的学生学号(男女之间浪漫),问你找出一个最大的集合保证集合内的任意两个学生之间没有相互浪漫关系,输出最大集合的人数. 注意:这里的浪漫边是双向的,如果1对2浪漫, 那么2对1也浪漫,题意好像没说清楚, 但我测了一下,是双向边. 思路:最大独立集和最小点覆盖集是互补的,所以 最大独立集 == 总人数n - 最小点覆盖集, 如果题目给你的是二分图那么直接二分匹配一下即可,但这题不是二分图,我们抓住双向边,那么我们进行拆点, 做一次匹配,求出来的匹配数是(左边男生匹配右…
Kindergarten Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 6956   Accepted: 3436 Description In a kindergarten, there are a lot of kids. All girls of the kids know each other and all boys also know each other. In addition to that, some…
#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…
(为什么最大独立集的背景都是严打搞对象的( _ _)ノ|壁) 思路:匈牙利算法 没什么可说的-- // by SiriusRen #include <cstdio> #include <cstring> using namespace std; int cases,n,tot,ans,first[555],next[555555],v[555555],fa[555],vis[555]; struct Student{int n;char sex[2],music[105],spor…
题目链接 题意 已知班级有g个女孩和b个男孩,所有女生之间都相互认识,所有男生之间也相互认识,给出m对关系表示哪个女孩与哪个男孩认识.现在要选择一些学生来组成一个集合,使得里面所有人都认识,求此集合最大人数. 思路 二分图的最大团的定义:对于一般图来说,团是一个顶点集合,且由该顶点集合诱导的子图是一个完全图,简单说,就是选出一些顶点,这些顶点两两之间都有边.最大团就是使得选出的这个顶点集合最大.对于二分图来说,我们默认为左边的所有点之间都有边,右边的所有顶点之间都有边.那么,实际上,我们是要在左…
题意 幼稚园里有m个男孩和n个女孩(m.n范围都是[1,200]),男孩之间相互认识,女孩之间也相互认识,另外有部分男孩和女孩也认识.现在要举办一个活动,选取一些同学,要求所有选取的同学之间两两相互认识. 思路 抽象一下问题就是:在图G中选择一个最大的子图G'(V', E'),使得∑u, v∈V',  (u, v)∈E',这就是最大团问题,也即最大完全子图问题. 一般性的最大团问题是NP问题,但是此题的图比较特殊,有g个点互相相连,b个点也互相相连,也就是说他们的补图是一个二分图.那么我们就可以…
Kindergarten Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 6191   Accepted: 3052 Description In a kindergarten, there are a lot of kids. All girls of the kids know each other and all boys also know each other. In addition to that, some…
Kindergarten Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 5884   Accepted: 2877 Description In a kindergarten, there are a lot of kids. All girls of the kids know each other and all boys also know each other. In addition to that, some…
题目链接:http://poj.org/problem?id=2771 Guardian of Decency Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 5517   Accepted: 2322 Description Frank N. Stein is a very conservative high-school teacher. He wants to take some of his students on…
题目链接: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…
链接:poj 1466 题意:有n个学生,每一个学生都和一些人有关系,如今要你找出最大的人数.使得这些人之间没关系 思路:求最大独立集,最大独立集=点数-最大匹配数 分析:建图时应该是一边是男生的点,一边是女生的点连边.可是题目中没说性别的问题.仅仅能将每一个点拆成两个点.一个当作是男的点,一个当作是女的点了,然后连边.因为关系是相互的.这样就造成了边的反复.也就是边集是刚才的二倍,从而导致了最大匹配变成了原本的二倍.因此,此时最大独立集=点数-最大匹配数/2. #include<stdio.h…
POJ 2724 Purifying Machine 题目链接 题意:这题题意有点没看懂.看了别人的题解, 给出m串长度为n的01串. 有些串中可能包括,这种串能够表示两个串,为1 和为0. 反复的算一种.比方题目中01 100 011 就代表了四个01串 001 101 100 011 如今我们须要消灭掉全部的01串,消灭方式有两种: 1一次消灭一个串. 2假设两个串的区别仅仅有一位的话能够同一时候消灭这两个串. 问最少多少次操作能够消灭全部的01串 思路:把存在的二进制数保存下来,然后去重.…
传送门:http://poj.org/problem?id=2771 Guardian of Decency Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 6456   Accepted: 2668 Description Frank N. Stein is a very conservative high-school teacher. He wants to take some of his students on…
题目地址:http://poj.org/problem?id=1419 Graph Coloring Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4468   Accepted: 2042   Special Judge Description You are to write a program that tries to find an optimal coloring for a given graph. Col…
Party at Hali-Bula Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 5660   Accepted: 2022 Description Dear Contestant, I'm going to have a party at my villa at Hali-Bula to celebrate my retirement from BCM. I wish I could invite all my co…
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…
Graph Coloring Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4893   Accepted: 2271   Special Judge Description You are to write a program that tries to find an optimal coloring for a given graph. Colors are applied to the nodes of the…
Guardian of Decency Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 5244   Accepted: 2192 Description Frank N. Stein is a very conservative high-school teacher. He wants to take some of his students on an excursion, but he is afraid that…