二分图
xuanweiace
一个热爱算法竞赛的弱校ACMer路过。青大本,浙大硕,方向后端开发,菜鸡一枚,奋斗ing...
展开
-
【HDU - 6016】Count the Sheep (思维,类似二分图)
题干:Altough Skipping the class is happy, the new term still can drive luras anxious which is of course because of the tests! Luras became worried as she wanted to skip the class, as well as to attend...原创 2018-09-13 11:44:39 · 307 阅读 · 0 评论 -
【SPOJ - TOURS 387】Travelling tours (最小费用最大流,拆点)
题干:In Hanoi, there are N beauty-spots (2 <= N <= 200), connected by M one-way streets. The length of each street does not exceed 10000. You are the director of a travel agency, and you want to...原创 2018-11-28 15:00:40 · 223 阅读 · 0 评论 -
【SPOJ - SCITIES】Selfish Cities (二分图最优匹配,最大费用流)
题干:Far, far away there is a world known as Selfishland because of the nature of its inhabitants. Hard times have forced the cities of Selfishland to exchange goods among each other. C1 cities are wi...原创 2018-11-28 15:04:23 · 364 阅读 · 0 评论 -
【 HDU - 5093】Battle ships(匈牙利算法,二分图匹配)
题干: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 geogr...原创 2019-03-16 09:33:43 · 246 阅读 · 0 评论 -
【HDU - 5090】Game with Pearls (匈牙利算法,二分图匹配)
题干:Tom and Jerry are playing a game with tubes and pearls. The rule of the game is:1) Tom and Jerry come up together with a number K.2) Tom provides N tubes. Within each tube, there are several ...原创 2019-03-16 10:46:18 · 221 阅读 · 0 评论 -
【BZOJ - 1059】矩阵游戏(二分图匹配,建图,最小边覆盖)
题干: 小Q是一个非常聪明的孩子,除了国际象棋,他还很喜欢玩一个电脑益智游戏——矩阵游戏。矩阵游戏在一个N*N黑白方阵进行(如同国际象棋一般,只是颜色是随意的)。每次可以对该矩阵进行两种操作:行交换操作:选择矩阵的任意两行,交换这两行(即交换对应格子的颜色)列交换操作:选择矩阵的任意行列,交换这两列(即交换对应格子的颜色)游戏的目标,即通过若干次操作,使得方阵的主对角线(左上角到...原创 2019-05-04 14:33:11 · 391 阅读 · 0 评论 -
【POJ - 3020】Antenna Placement (匈牙利算法,二分图最小边覆盖)
题干: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 why they got the job, is their discovery of ...原创 2019-05-04 16:49:27 · 265 阅读 · 0 评论 -
【POJ - 2195】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 man, you n...原创 2019-05-04 17:33:49 · 256 阅读 · 0 评论 -
【POJ - 1486】Sorting Slides(思维建图,二分图求必须边,关建边,图论)
题干:Professor Clumsey is going to give an important talk this afternoon. Unfortunately, he is not a very tidy person and has put all his transparencies on one big heap. Before giving the talk, he has...原创 2019-05-04 21:13:32 · 279 阅读 · 0 评论 -
【HDU - 1533】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 man, you n...原创 2019-04-25 10:04:16 · 415 阅读 · 0 评论 -
【2018ACM山东省赛 - B】Bullet(二分 + 二分图匹配,匈牙利算法,卡常)
题干:Problem DescriptionIn GGO, a world dominated by gun and steel, players are fighting for the honor of being the strongest gunmen. Player Shino is a sniper, and her aimed shot kills one monster a...原创 2019-05-09 21:27:13 · 440 阅读 · 1 评论 -
【FZU - 2039】Pets(二分图匹配,水题)
题干:有n个人,m条狗,然后会给出有一些人不喜欢一些狗就不会购买,问最多能卖多少狗。。InputThere is a single integer T in the first line of the test data indicating that there are T(T≤100) test cases. In the first line of each test case,...原创 2019-05-07 22:27:48 · 203 阅读 · 0 评论 -
【POJ - 3041】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 co...原创 2018-11-15 18:47:09 · 211 阅读 · 0 评论 -
【POJ - 1463】Strategic game (树上最小点覆盖,树形dp)
题干: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 me...原创 2018-11-14 16:42:43 · 502 阅读 · 0 评论 -
算法讲解 -- 二分图之 匈牙利算法
匈牙利算法是由匈牙利数学家Edmonds于1965年提出,因而得名。匈牙利算法是基于Hall定理中充分性证明的思想,它是部图匹配最常见的算法,该算法的核心就是寻找增广路径,它是一种用增广路径求二分图最大匹配的算法。-------等等,看得头大?那么请看下面的版本: 通过数代人的努力,你终于赶上了剩男剩女的大潮,假设你是一位光荣的新世纪媒人,在你的手上有N个剩男,M个剩女,每个人都可能对...转载 2018-10-04 16:09:17 · 793 阅读 · 0 评论 -
【HDU - 2444】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 o...原创 2018-10-25 22:53:16 · 279 阅读 · 0 评论 -
*【HDU - 2819】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?InputThere are several test c...原创 2018-10-14 14:32:03 · 257 阅读 · 0 评论 -
【HDU - 1281 】棋盘游戏 (经典的二分图匹配,匈牙利算法,枚举删除顶点,必须边,关建边)
题干:小希和Gardon在玩一个游戏:对一个N*M的棋盘,在格子里放尽量多的一些国际象棋里面的“车”,并且使得他们不能互相攻击,这当然很简单,但是Gardon限制了只有某些格子才可以放,小希还是很轻松的解决了这个问题(见下图)注意不能放车的地方不影响车的互相攻击。所以现在Gardon想让小希来解决一个更难的问题,在保证尽量多的“车”的前提下,棋盘里有些格子是可以避开的,也就是说,不在这些格...原创 2018-10-14 16:36:53 · 461 阅读 · 0 评论 -
【POJ - 2226】Muddy Fields(匈牙利算法 或 网络流dinic,二分图匹配,最小点覆盖,矩阵中优秀的建图方式 )
题干: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, the rain makes some patches of bare earth quite m...原创 2018-10-15 21:05:26 · 385 阅读 · 0 评论 -
【HDU - 4185】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...原创 2018-10-17 00:43:32 · 269 阅读 · 0 评论 -
【HDU - 1045】Fire Net (dfs 或二分图)
题干:Suppose that we have a square city with straight streets. A map of a city is a square board with n rows and n columns, each representing a street or a piece of wall. A blockhouse is a small cast...原创 2018-10-17 00:54:35 · 225 阅读 · 0 评论 -
【HDU - 2255】奔小康赚大钱(KM算法模板,二分图最优匹配)
题干:传说在遥远的地方有一个非常富裕的村落,有一天,村长决定进行制度改革:重新分配房子。 这可是一件大事,关系到人民的住房问题啊。村里共有n间房间,刚好有n家老百姓,考虑到每家都要有房住(如果有老百姓没房子住的话,容易引起不安定因素),每家必须分配到一间房子且只能得到一间房子。 另一方面,村长和另外的村领导希望得到最大的效益,这样村里的机构才会有钱.由于老百姓都比较富裕,他们都能对每一间房...原创 2018-10-19 23:31:42 · 434 阅读 · 0 评论 -
【UVA - 11383】Claw Golden Tiger (二分图最优匹配,KM算法原理)
题干: 粘贴不过来。。。题目大意: 500*500带权格子,每行每列要确定一个值,使row[i]+col[j] >= val[i][j],要使所有row值和col值的和最小输出每行的row[i],和每列的col[i]。解题报告: 跑一边KM,自带着就把我们需要的期望值给求出来了。AC代码:#include <iostream>#...原创 2018-10-20 11:40:42 · 254 阅读 · 0 评论 -
【UVALive - 3126】Taxi Cab Scheme (二分图,最小路径覆盖)
题目大意:有n个出车安排,一辆车能接到这个安排的条件是:1、这辆车第一次发车;2、这辆车接了上一个安排,回到这个安排的起点的时间正好是这个安排的前一分钟或者更早解题报告: 建图然后跑最小路径覆盖。就是答案。注意搭边的条件不是光看距离,还要加上每个任务的起点到终点的时间。AC代码:(116ms)#include<bits/stdc++.h>using nam...原创 2018-10-25 22:48:32 · 254 阅读 · 0 评论 -
【HDU - 1083 】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 th...原创 2018-10-25 22:52:49 · 184 阅读 · 0 评论 -
【POJ - 2942】Knights of the Round Table(点双连通分量,二分图判断奇环奇圈)
题干:Being a knight is a very attractive career: searching for the Holy Grail, saving damsels in distress, and drinking with the other knights are fun things to do. Therefore, it is not very surprisin...原创 2019-07-19 18:30:04 · 352 阅读 · 0 评论