随笔分类 -  图论之二分图匹配

摘要:``` // pragma comment(linker, "/stack:200000000") // pragma GCC optimize("Ofast,no stack protector") // pragma GCC target("sse,sse2,sse3,ssse3,sse4,po 阅读全文
posted @ 2018-08-06 21:54 walfy 阅读(298) 评论(0) 推荐(0)
摘要:题意:在遥远的东方,有一个神秘的民族,自称Y族。他们世代居住在水面上,奉龙王为神。每逢重大庆典, Y族都会在水面上举办盛大的祭祀活动。我们可以把Y族居住地水系看成一个由岔口和河道组成的网络。每条河道连接着两个岔口,并且水在河道内按照一个固定的方向流动。显然,水系中不会有环流(下图描述一个环流的例子) 阅读全文
posted @ 2018-06-01 15:49 walfy 阅读(148) 评论(0) 推荐(0)
摘要:https://www.lydsy.com/JudgeOnline/problem.php?id=1059 裸的二分图匹配,行列匹配即可 /************************************************************** Problem: 1059 Use 阅读全文
posted @ 2018-04-20 15:53 walfy 阅读(136) 评论(0) 推荐(0)
摘要:题意:有一些牛和牛棚(有容量),每头牛对牛棚有喜好程度,要求每头牛都有一个棚子的情况下,找最小的喜好程度之差 题解:题意是真的恶心,wa了好久才发现没读懂,一直以为输入 的是排名,其实是牛棚标号,从1到m。用最大流一直tle,无奈还是用匈牙利算法,对于匈牙利算法求解二分图多重匹配,可以用一个容量数组 阅读全文
posted @ 2017-11-15 10:45 walfy 阅读(182) 评论(0) 推荐(0)
摘要:题意:给一堆点,一部分是牛,一部分是机器,每头牛必须要走到一个机器,每个点之间有距离,要求每头牛都能找得到一台机器(机器有最大容量)的情况下,走的最远的牛距离最小 题解:二分答案,小于该距离的边才能加进来,先用floyd预处理距离,然后跑最大流看满不满足条件 #include<map> #inclu 阅读全文
posted @ 2017-11-13 20:16 walfy 阅读(196) 评论(0) 推荐(0)
摘要:题意:给你一张二分图,求右边点到汇点的最小容量(保证流量为n)是多少 题解:二分答案,每次重新建边跑最大流,看是不是为n就好了 #include<map> #include<set> #include<cmath> #include<queue> #include<stack> #include<v 阅读全文
posted @ 2017-11-13 15:42 walfy 阅读(213) 评论(0) 推荐(0)
摘要:给一个数组,对于每两个数加起来为素数那么就是一个集合,求不超过k个集合的最多数是多少 解法:二分图匹配,先打素数筛,预处理边集,匹配完之后分两种情况k>匹配数,那么可以直接输出匹配数*2,否则可以选取匹配数*2+min(k-匹配数,剩余没有匹配的而且有边的点),这里是因为没有匹配的点有边,连着之前匹 阅读全文
posted @ 2017-11-05 01:11 walfy 阅读(453) 评论(0) 推荐(0)
摘要: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 child's like-an 阅读全文
posted @ 2017-04-22 21:57 walfy 阅读(114) 评论(0) 推荐(0)
摘要:传递闭包最开始是在Floyd-Warshall算法里面出现的,当时这算法用的很少就被我忽视了。。 传递闭包是指如果i能到达k,并且k能到达j,那么i就能到达j Have you ever read any book about treasure exploration? Have you ever 阅读全文
posted @ 2017-04-22 19:58 walfy 阅读(429) 评论(0) 推荐(0)
摘要:有向图的最小路径覆盖=V-二分图最大匹配。 Consider a town where all the streets are one-way and each street leads from one intersection to another. It is also known that 阅读全文
posted @ 2017-04-22 19:30 walfy 阅读(805) 评论(0) 推荐(0)
摘要:最小定点覆盖是指这样一种情况: 图G的顶点覆盖是一个顶点集合V,使得G中的每一条边都接触V中的至少一个顶点。我们称集合V覆盖了G的边。最小顶点覆盖是用最少的顶点来覆盖所有的边。顶点覆盖数是最小顶点覆盖的大小。 相应地,图G的边覆盖是一个边集合E,使得G中的每一个顶点都接触E中的至少一条边。如果只说覆 阅读全文
posted @ 2017-04-22 18:59 walfy 阅读(2393) 评论(0) 推荐(0)
摘要:The Global Aerial Research Centre has been allotted the task of building the fifth generation of mobile phone nets in Sweden. The most striking reason 阅读全文
posted @ 2017-04-21 15:17 walfy 阅读(1322) 评论(0) 推荐(0)
摘要:Thanks to a certain "green" resources company, there is a new profitable industry of oil skimming. There are large slicks of crude oil floating in the 阅读全文
posted @ 2017-04-20 23:54 walfy 阅读(189) 评论(0) 推荐(0)
摘要:You’re giving a party in the garden of your villa by the sea. The party is a huge success, and everyone is here. It’s a warm, sunny evening, and a soo 阅读全文
posted @ 2017-04-20 18:24 walfy 阅读(477) 评论(0) 推荐(0)
摘要:Given an N*N matrix with each entry equal to 0 or 1. You can swap any two rows or any two columns. Can you find a way to make all the diagonal entries 阅读全文
posted @ 2017-04-20 18:20 walfy 阅读(117) 评论(0) 推荐(0)
摘要:小希和Gardon在玩一个游戏:对一个N*M的棋盘,在格子里放尽量多的一些国际象棋里面的“车”,并且使得他们不能互相攻击,这当然很简单,但是Gardon限制了只有某些格子才可以放,小希还是很轻松的解决了这个问题(见下图)注意不能放车的地方不影响车的互相攻击。 所以现在Gardon想让小希来解决一个更 阅读全文
posted @ 2017-04-19 11:45 walfy 阅读(133) 评论(0) 推荐(0)
摘要:There are a group of students. Some of them may know each other, while others don't. For example, A and B know each other, B and C know each other. Bu 阅读全文
posted @ 2017-04-18 23:05 walfy 阅读(183) 评论(0) 推荐(0)
摘要:onsider 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 possible 阅读全文
posted @ 2017-04-18 21:54 walfy 阅读(589) 评论(0) 推荐(0)