poj 2771 最大独立集】的更多相关文章

这道题又无耻的抄袭了别人的代码. 刚开始以为是最大匹配,把条件不相符的人连一起,然后求最大匹配,感觉麻烦,然后看了别人的解题报告,是把相符的人连一起,然后减去,其实就是最大独立集. 最大独立集=|G|-最大匹配. 首先先把性别分开,因为同性不能成为couple,然后把符合条件的异性连一起,然后就是最大匹配了. #include<stdio.h> #include<string.h> #define maxn 505 #define maxl 106 struct Person {…
(为什么最大独立集的背景都是严打搞对象的( _ _)ノ|壁) 思路:匈牙利算法 没什么可说的-- // 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…
poj——2771    Guardian of Decency Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 5916   Accepted: 2458 Description Frank N. Stein is a very conservative high-school teacher. He wants to take some of his students on an excursion, but he i…
题目链接: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=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=2771 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 some of them might become couples. While you can never exclude th…
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…
Problem DescriptionFrank 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 some of them might become couples. While you can never exclude this possibility, he has made so…
题目链接:http://poj.org/problem?id=2771 题目意思:有一个保守的老师要带他的学生来一次短途旅行,但是他又害怕有些人会变成情侣关系,于是就想出了一个方法: 1.身高差距  > 40cm 2.相同性别 3.喜欢的音乐种类  不同 4.有共同喜爱的 运动 只要满足其中这4个条件中的一个(当然越多越好啦),就可以将他们编为一组啦(一组两个人),求能被编为一组的最多组数. 这题实质上求的是二分图的最大独立集.  最大独立集 = 顶点数 - 最大匹配数 可以这样转化:两个人至少…
http://poj.org/problem?id=2771 题意: 一个老师想带几个同学出去,但是他怕他们会谈恋爱,所以带出去的同学两两之间必须满足如下条件之一: ①身高差大于40  ②同性 ③喜欢的音乐风格不同 ④喜欢的运动相同 思路: 每两个人之间进行判断,如果不满足上面4个之一,则连一条线,说明他们是不能同时带出去的.然后找一个最大匹配,说明这几对中每队只能带出去一人,这样答案就很明显了. #include<iostream> #include<cstdio> #inclu…