二分图
爱上键盘的小哥哥
这个作者很懒,什么都没留下…
展开
-
Courses
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 possible to form a committee of exactly P students that sa原创 2017-11-28 21:11:46 · 391 阅读 · 0 评论 -
The Perfect Stall (二分图的最大匹配)
Farmer John completed his new barn just last week, complete with all the latest milking technology. Unfortunately, due to engineering problems, all the stalls in the new barn are different. For the fi原创 2018-02-04 12:20:45 · 411 阅读 · 0 评论 -
奔小康赚大钱 (最佳匹配 ——KM()算法)
传说在遥远的地方有一个非常富裕的村落,有一天,村长决定进行制度改革:重新分配房子。 这可是一件大事,关系到人民的住房问题啊。村里共有n间房间,刚好有n家老百姓,考虑到每家都要有房住(如果有老百姓没房子住的话,容易引起不安定因素),每家必须分配到一间房子且只能得到一间房子。另一方面,村长和另外的村领导希望得到最大的效益,这样村里的机构才会有钱.由于老百姓都比较富裕,他们都能对每一间房子在原创 2018-02-05 10:00:00 · 171 阅读 · 0 评论 -
Rain on your Parade (Hopcroft-Karp算法)
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 soothing wind sends fresh, salty air from the sea. Th原创 2018-01-29 10:14:51 · 343 阅读 · 0 评论 -
50 years, 50 colors (二分图的最小点覆盖)
On Octorber 21st, HDU 50-year-celebration, 50-color balloons floating around the campus, it's so nice, isn't it? To celebrate this meaningful day, the ACM team of HDU hold some fuuny games. Especially原创 2018-02-05 13:11:25 · 231 阅读 · 0 评论 -
Trash (KM算法)
You were just hired as CEO of the local junkyard.One of your jobs is dealing with the incoming trash and sorting it for recycling.The trash comes every day inN containers and each of these container原创 2018-02-05 14:20:50 · 289 阅读 · 0 评论 -
Ants (KM算法)
Young naturalist Bill studies ants in school. His ants feed on plant-louses that live on apple trees. Each ant colony needs its own apple tree to feed itself.Bill has a map with coordinates of n ant原创 2018-02-05 16:41:58 · 306 阅读 · 0 评论 -
Hopcroft-Karp算法
Hopcroft-Karp算法该算法由John.E.Hopcroft和Richard M.Karp于1973提出,故称Hopcroft-Karp算法。原理为了降低时间复杂度,可以在增广匹配集合M时,每次寻找多条增广路径。这样就可以进一步降低时间复杂度,可以证明,算法的时间复杂度可以到达O(n^0.5*m),虽然优化不了多少,但在实际应用时,效果还是很明显的。基本算法该算法主要是对匈牙利算法的优化,...原创 2018-01-27 21:31:40 · 1062 阅读 · 0 评论 -
Tour (KM算法+取反)
In the kingdom of Henryy, there are N (2 <= N <= 200) cities, with M (M <= 30000) one-way roads connecting them. You are lucky enough to have a chance to have a tour in the kingdom. The rou...原创 2018-04-26 11:21:35 · 164 阅读 · 0 评论 -
Oil Skimming (二分图)
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 Gulf of Mexico just waiting to be scooped up by...原创 2018-04-26 15:16:34 · 314 阅读 · 0 评论 -
Going Home (KM算法)
On a grid map there are n little men and n houses. In each unit time, every little man can move one unit step, either horizontally, or vertically, to an adjacent point. For each little ma...原创 2018-04-26 17:01:24 · 370 阅读 · 0 评论 -
The King’s Problem HDU - 3861(tarjan缩点+最小路径覆盖)
In the Kingdom of Silence, the king has a new problem. There are N cities in the kingdom and there are M directional roads between the cities. That means that if there is a road from u to v, you can...原创 2018-05-17 21:13:04 · 287 阅读 · 0 评论 -
趣写算法系列之--匈牙利算法
书本上的算法往往讲得非常复杂,我和我的朋友计划用一些简单通俗的例子来描述算法的流程】匈牙利算法是由匈牙利数学家Edmonds于1965年提出,因而得名。匈牙利算法是基于Hall定理中充分性证明的思想,它是部图匹配最常见的算法,该算法的核心就是寻找增广路径,它是一种用增广路径求二分图最大匹配的算法。-------等等,看得头大?那么请看下面的版本:通过数代人的努力,你终于赶上转载 2017-11-28 19:38:03 · 304 阅读 · 0 评论 -
Battle ships HDU - 5093(建图+二分图匹配)
Dear contestant, now you are an excellent navy commander, who is responsible of a tough mission currently.Your fleet unfortunately encountered an enemy fleet near the South Pole where the geographica...原创 2018-07-16 20:57:25 · 132 阅读 · 0 评论 -
Detachment HDU - 5976(染色法)
In a highly developed alien society, the habitats are almost infinite dimensional space.In the history of this planet,there is an old puzzle.You have a line segment with x units’ length representing...原创 2018-07-21 15:48:24 · 277 阅读 · 0 评论 -
Strategic Game (最小点覆盖)
Bob enjoys playing computer games, especially strategic games, but sometimes he cannot find the solution fast enough and then he is very sad. Now he has the following problem. He must defend a medieva原创 2018-02-04 11:15:39 · 200 阅读 · 0 评论 -
HDU-1350 Taxi Cab Scheme(最小路径覆盖)
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 the customers calling to get a cab as soon as possible, ther原创 2018-01-28 12:06:28 · 173 阅读 · 0 评论 -
Treasure Exploration (最少路径覆盖+传递闭包)
Have you ever read any book about treasure exploration? Have you ever see any film about treasure exploration? Have you ever explored treasure? If you never have such experiences, you would never know原创 2018-01-28 10:51:23 · 187 阅读 · 0 评论 -
棋盘游戏 (二分图的最大匹配)
小希和Gardon在玩一个游戏:对一个N*M的棋盘,在格子里放尽量多的一些国际象棋里面的“车”,并且使得他们不能互相攻击,这当然很简单,但是Gardon限制了只有某些格子才可以放,小希还是很轻松的解决了这个问题(见下图)注意不能放车的地方不影响车的互相攻击。所以现在Gardon想让小希来解决一个更难的问题,在保证尽量多的“车”的前提下,棋盘里有些格子是可以避开的,也就是说,不在这些格子上放原创 2017-11-30 08:58:25 · 242 阅读 · 0 评论 -
Swap
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 equal to 1?Input There are several test cas原创 2017-11-30 16:06:09 · 190 阅读 · 0 评论 -
Air Raid(最小路径覆盖)
Consider a town where all the streets are one-way and each street leads from one intersection to another. It is also known that starting from an intersection and walking through town's streets you can原创 2017-12-07 11:02:09 · 368 阅读 · 0 评论 -
二分图大讲堂——彻底搞定最大匹配数(最小覆盖数)、最大独立数、最小路径覆盖、带权最优匹配
转载:http://dsqiu.iteye.com/blog/1689505文本内容框架:§1图论点、边集和二分图的相关概念和性质§2二分图最大匹配求解匈牙利算法、Hopcroft-Karp算法§3二分图最小覆盖集和最大独立集的构造§4二分图最小路径覆盖求解§5二分图带权最优匹配求解Kuhn-Munkers算法§6小结每章节都详细地讲解了问题介绍,算法原转载 2017-12-07 11:11:54 · 313 阅读 · 0 评论 -
Catch(HDU2478)
Problem DescriptionA thief is running away!We can consider the city where he locates as an undirected graph in which nodes stand for crosses and edges stand for streets. The crosses are labeled fr原创 2018-01-25 16:31:32 · 226 阅读 · 0 评论 -
图论之二分图的判定
二分图定义:简而言之,就是顶点集V可分割为两个互不相交的子集,并且图中每条边依附的两个顶点都分属于这两个互不相交的子集,两个子集内的顶点不相邻。二分图是这样一个图:有两顶点集且图中每条边的的两个顶点分别位于两个顶点集中,每个顶点集中没有边直接相连接。判定方法——染色法: 开始对任意一未染色的顶点染色,之后判断其相邻的顶点中,若未染色则将其染上和相邻顶点不同的颜色,原创 2018-01-25 15:38:08 · 394 阅读 · 0 评论 -
The Accomodation of Students(二分图的判断+二分图的最大匹配)
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. But this may not imply that A and C know each other.原创 2017-11-28 19:43:10 · 610 阅读 · 0 评论 -
4个数和为0 51Nod - 1267 (二分法)
给出N个整数,你来判断一下是否能够选出4个数,他们的和为0,可以则输出"Yes",否则输出"No"。Input 第1行,1个数N,N为数组的长度(4 第2 - N + 1行:Ai(-10^9 iOutput 如果可以选出4个数,使得他们的和为0,则输出"Yes",否则输出"No"。 Sample Input 5-11-524Sample Output Yes原创 2018-01-27 10:56:55 · 146 阅读 · 0 评论 -
过山车 (二分图的最大匹配)
RPG girls今天和大家一起去游乐场玩,终于可以坐上梦寐以求的过山车了。可是,过山车的每一排只有两个座位,而且还有条不成文的规矩,就是每个女生必须找个个男生做partner和她同坐。但是,每个女孩都有各自的想法,举个例子把,Rabbit只愿意和XHD或PQK做partner,Grass只愿意和linle或LL做partner,PrincessSnow愿意和水域浪子或伪酷儿做partner。考虑原创 2018-02-03 17:14:58 · 148 阅读 · 0 评论 -
Ollivanders: Makers of Fine Wands since 382 BC(二分图的最大匹配)
In Diagon Alley ,there is only one Wand-seller,peeling gold letters over the door read Ollivanders: Makers of Fine Wands since 382 BC.A single wand lay on a faded purple cushion in the dusty window.原创 2018-02-03 17:55:07 · 591 阅读 · 0 评论 -
Girls and Boys (最大独立集)
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 stud原创 2018-01-27 17:39:46 · 237 阅读 · 0 评论 -
HDU-3829 Cat VS Dog(最大独立集)
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-animal is a cat, then his/hers dislike-animal must b...原创 2018-01-27 17:42:43 · 188 阅读 · 0 评论 -
Asteroids (最小点覆盖)
Bessie wants to navigate her spaceship through a dangerous asteroid field in the shape of an N x N grid (1 <= N <= 500). The grid contains K asteroids (1 <= K <= 10,000), which are conveniently locate原创 2018-01-27 18:10:46 · 297 阅读 · 0 评论 -
Selecting Courses(二分图的最大匹配)
It is well known that it is not easy to select courses in the college, for there is usually conflict among the time of the courses. Li Ming is a student who loves study every much, and at the beginnin原创 2018-02-03 18:55:57 · 696 阅读 · 0 评论 -
Friends and Enemies HDU - 5874(思维)
On an isolated island, lived some dwarves. A king (not a dwarf) ruled the island and the seas nearby, there are abundant cobblestones of varying colors on the island. Every two dwarves on the island a...原创 2018-08-31 11:04:53 · 206 阅读 · 1 评论