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…
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…
题意:给出每个学生的标号及与其有缘分成为情侣的人的标号,求一个最大集合,集合中任意两个人都没有缘分成为情侣. 分析: 1.若两人有缘分,则可以连一条边,本题是求一个最大集合,集合中任意两点都不相连,即最大独立集问题. 2.最大独立集 = 顶点数 - 最大匹配数(匈牙利算法求解). 3.将一个人拆成两个相同的人进行二分匹配,因此真正的最大匹配数应为得到的最大匹配数/2. #pragma comment(linker, "/STACK:102400000, 102400000") #inc…
题意:除了所给的一些点外,问能不能用1*2的矩形覆盖所有的点,矩形间不能重叠. 思路:简单二分匹配,,,,,,, #include<stdio.h> #include<string.h> const int N=1200; int match[N],link[N],map[35][35],n,m; int dir[4][2]={0,1,0,-1,1,0,-1,0}; int find(int u) { int i,v,x,y,X,Y; x=u/m;y=u%m; for(i=0;i&…
题意:有水平N张牌,竖直M张牌,同一方向的牌不会相交.水平的和垂直的可能会相交,求最少踢出去几张牌使剩下的牌都不相交. 二分匹配 最小点覆盖=最大匹配. 链接:点我 坐标点作为匹配的端点 #include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<cmath> #include<queue> #include<map>…
Cat VS Dog Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 125536/65536 K (Java/Others) Problem Description The zoo have N cats and M dogs, today there are P children visiting the zoo, each child has a like-animal and a dislike-animal, if the ch…
m种阳离子 n种阴离子 然后一个m*n的矩阵 第i行第j列为1代表第i种阴离子和第j种阴离子相互吸引 0表示排斥 求在阳离子和阴离子都至少有一种的情况下 最多存在多少种离子能够共存 阴阳离子都至少须要存在一种 那么能够枚举哪2种离子共存 如果枚举a b 然后找到全部的和a能够共存的阴离子(设为x集合)以及和b共存的阳离子(设为y集合) 如今仅仅需求x集合中和y集合中最多有多少个离子能够共存 这个求最大独立集即可了 枚举全部的a b 取最大值 #include <cstdio> #include…
题目链接:[http://acm.hdu.edu.cn/showproblem.php?pid=1498] 题意:给出一个大小为n*n(0<n<100)的矩阵,矩阵中放入m种颜色(标号为1-m),然后对于每种颜色有k次操作,每次操作可以选择一行或者一列,然后把这一行或者这一列的这种颜色全部去掉,求每种颜色k次操作以后,不能去掉的颜色是哪几种颜色,从小到大输出. 最小顶点覆盖要求用最少的点(X或Y中都行),让每条边都至少和其中一个点关联.Knoig定理:二分图的最小顶点覆盖数等于二分图的最大匹配…
传送门: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…
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…
有n个人, 其中有男生和女生,接着有n行,分别给出了每一个人暗恋的对象(不止暗恋一个) 现在要从这n个人中找出一个最大集合,满足这个集合中的任意2个人,都没有暗恋这种关系. 输出集合的元素个数. 刚开始想,把人看成顶点,若有暗恋的关系,就连一条边,构成一个图 独立集的概念:一个图中两两互不相连的顶点集合 所以这道题,就是要求最大独立集 有:最大独立集+最小顶点覆盖=|V|(顶点的总个数) 那就求最小顶点覆盖了 根据题意: 暗恋的对象性别不同,所以a暗恋b,b暗恋c,c暗恋a这种关系不可能存在 也…
Guardian of Decency Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 6133   Accepted: 2555 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…
Girls and Boys Time Limit: 5000MS   Memory Limit: 10000K Total Submissions: 11694   Accepted: 5230 Description In the second year of the university somebody started a study on the romantic relations between the students. The relation "romantically in…
题意:有N个人,已知身高.性别.音乐.运动.要求选出尽可能多的人,使这些人两两之间至少满足下列四个条件之一. 1.身高差>40  2.性别相同  3.音乐不同  4.运动相同 分析: 1.很显然性别相同的人一定能一起去,问题就在于如何在这些性别相同的人中加入性别不同的人. 2.把男女分开,进行二分匹配. 如果某个男生A与任何一个女生都满足条件1.3.4之一,那这个男生就可以和这些女生一起选择. 反之,如果按照男女之间不满足条件1.3.4中的任何一个的原则连线,那么诸如男生A这样的男生是不会与任何…
题目链接: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…
/** 题目:Guardian of Decency UVALive - 3415 最大独立集=结点数-最大匹配数 老师带大学生旅游 链接:https://vjudge.net/problem/UVALive-3415 题意:老师带学生去旅游,要求从n个学生中选出一些学生,满足任意两个学生至少要满足下面的四条中的一条. 1,身高相差大于40cm 2,性别相同 3,最喜欢的音乐不同类型 4,最喜欢的体育比赛相同类型 输出可以挑选的最多学生人数. 思路:最大独立集做法. 选出来的学生必须满足上面四个…
The Perfect Stall Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24081   Accepted: 10695 Description Farmer John completed his new barn just last week, complete with all the latest milking technology. Unfortunately, due to engineering p…
The Perfect Stall Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 16396   Accepted: 7502 Description Farmer John completed his new barn just last week, complete with all the latest milking technology. Unfortunately, due to engineering pr…
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…
uva 12083 Guardian of Decency 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 this poss…
题目链接:http://poj.org/problem?id=3057 题目大概意思是有一块区域组成的房间,房间的边缘有门和墙壁,'X'代表墙壁,'D'代表门,房间内部的' . '代表空区域,每个空区域站一个人,人可以向上下左右走,每走一步花费一秒钟,现在房间起火了,所有人向四周的门逃生,但是每秒钟一扇门只能通过一个人,每个人移动到门时,就算逃脱,问在选取使得所有人最优的逃生方案时,最后一个逃生的人花费多长时间?如果有人无法逃生,输出impossible. 题目建图思路比较难想.考虑到任意 t…
Taxi Cab Scheme Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 5710   Accepted: 2393 Description Running a taxi station is not all that simple. Apart from the obvious demand for a centralised coordination of the cabs in order to pick up…
COURSES Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 18993   Accepted: 7486 Description Consider a group of N students and P courses. Each student visits zero, one or more than one courses. Your task is to determine whether it is poss…
The dog task Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2559   Accepted: 1038   Special Judge Description Hunter Bob often walks with his dog Ralph. Bob walks with a constant speed and his route is a polygonal line (possibly self-in…
这道题实现起来还是比较简单的,但是理解起来可能有点困难. 我最开始想到的是贪心法,每次消灭当前小行星最多的一行或一列.然而WA了.Discuss区里已经有高人给出反例. 下面给出正确的解法 我们把行和列抽象成点,把小行星抽象成边,每出现一个小行星,就把其行列所对应的点连起来.这样就形成了一个无向图$G=\left(V, E\right)$.问题就转化为了求这个图G中的最小点覆盖,即求一个元素数量尽可能小的点集$V' \subset V$,$E$中的所有边均与其内的一点相连. 最小点覆盖问题是一个…
Muddy Fields Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9754   Accepted: 3618 Description Rain has pummeled the cows' field, a rectangular grid of R rows and C columns (1 <= R <= 50, 1 <= C <= 50). While good for the grass, t…
Purifying Machine Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 5004   Accepted: 1444 Description Mike is the owner of a cheese factory. He has 2N cheeses and each cheese is given a binary number from 00...0 to 11...1. To keep his chee…
二分匹配:二分图的一些性质 二分图又称作二部图,是图论中的一种特殊模型. 设G=(V,E)是一个无向图,如果顶点V可分割为两个互不相交的子集(A,B),并且图中的每条边(i,j)所关联的两个顶点i和j分别属于这两个不同的顶点集(i in A,j in B),则称图G为一个二分图. 1.一个二分图中的最大匹配数等于这个图中的最小点覆盖数 König定理是一个二分图中很重要的定理,它的意思是,一个二分图中的最大匹配数等于这个图中的最小点覆盖数.如果你还不知道什么是最小点覆盖,我也在这里说一下:假如选…
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=237 二分匹配--最小点覆盖模板题 Tips:用邻接矩阵超时,用数组模拟邻接表WA,暂时只有vector<>过了! 代码如下: //最小点覆盖 = 最大匹配数 //最大独立集 = N - 最大匹配数 #include "stdio.h" //二分匹配,求最小点覆盖 #include "string.h" #include "vector…
Warm up 2 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 28    Accepted Submission(s): 8 Problem Description Some 1×2 dominoes are placed on a plane. Each dominoe is placed either horizontally…