
图论-二分图匹配
文章平均质量分 68
JeraKrs
本人目前就职于百度商业研发部,有需要内推的朋友简历可发我邮箱 jerakrs@qq.com
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Codeforces 387D George and Interesting Graph(二分图匹配)
题目链接:Codeforces 387D George and Interesting Graph 题目大意:定义一种有趣图:有向无子环图,存在一个根磨合任意节点有一去路和一回路(本身也有),然后除去根以外的所有点的入度和出度均为2。现在给出一张图,问说最少给进行几次操作可以使得图变成有趣图,操作可以是删除和添加一条边。 解题思路:枚举根,判断以该节点为根需要几次操作,维护最小原创 2014-02-01 23:58:33 · 2286 阅读 · 0 评论 -
hdu 4685 Prince and Princess(二分图匹配 + 强连通)
题目链接:hdu 4685 Prince and Princess解题思路K为当前最大匹配数,王子增加M-K个虚拟点用来匹配没有配对成功的公主,公主增加N-K的虚拟点用来匹配没有配对成功的王子,然后从公主建一条反向边到其配对的王子,做一次强连通,属于同一联通分量的王子和公主可以配对。代码#include <cstdio> #include <cstring> #include <vector> #i原创 2015-11-13 11:11:42 · 872 阅读 · 0 评论 -
uva 1045 - The Great Wall Game(二分图匹配)
题目链接:uva 1045 - The Great Wall Game 枚举最终移动到的行和列,以及两条对角线,建立二分图,X集合为棋子,Y集合为目标位置,边权为棋子移动到目标位置的代价,做完美匹配,求最小值。 #include #include #include #include #include using namespace std; const int ma原创 2015-09-23 21:50:32 · 1362 阅读 · 0 评论 -
uva 1006 - Fixed Partition Memory Management(完美匹配)
题目链接:uva 1006 - Fixed Partition Memory Management 以任务为X,Y为每个处理器在倒数第几个完成,任务xi连向yj的边权值即为任务xi对处理器的时间贡献值,用KM算法求解。 #include #include #include #include using namespace std; const int maxn = 5原创 2015-09-23 21:47:34 · 1066 阅读 · 0 评论 -
uva 1459 - Flowers Placement(二分图匹配+暴力)
题目链接:uva 1459 - Flowers Placement 暴力,在暴力的基础上用二分图匹配剪枝,如果当前位置放k,导致后面的位置不能匹配,即可回溯。 #include #include #include #include using namespace std; const int maxn = 205; int N, M, K, cnt, L[maxn]原创 2015-09-23 22:40:22 · 745 阅读 · 0 评论 -
uva 1411 - Ants(几何+完美匹配)
题目连接:uva 1411 - Ants 以两点间距离做权值,建图,做完美匹配。如果两线段AB与CD向交,那么AD或者BC边的权值小于AB和CD。 #include #include #include #include using namespace std; const int maxn = 105; const double eps = 1e-9; struct原创 2015-09-23 22:34:58 · 1342 阅读 · 0 评论 -
uva 1349 - Optimal Bus Route Design(完美匹配)
题目链接:uva 1349 - Optimal Bus Route Design 权值变为负的即便为求最小值。 #include #include #include #include using namespace std; const int maxn = 105; const int inf = 0x3f3f3f3f; int N, L[maxn], Lx[ma原创 2015-09-23 22:27:45 · 896 阅读 · 0 评论 -
uva 12168 - Cat vs. Dog(二分图匹配)
题目链接:uva 12168 - Cat vs. Dog 类似uva 12083 #include #include #include #include #include using namespace std; const int maxn = 505; typedef pair pii; int N, M, K, L[maxn]; bool T[maxn];原创 2015-09-23 22:20:02 · 831 阅读 · 0 评论 -
uva 12083 - Guardian of Decency(二分图匹配)
题目链接:uva 12083 - Guardian of Decency 对于男女可以分成X和Y,矛盾的两个人之间建立一条边, 做二分图最大匹配,每条被选取的边表示只能有一人被选中。 #include #include #include #include #include #include #include using namespace std; const原创 2015-09-23 22:17:01 · 865 阅读 · 0 评论 -
uva 1201 - Taxi Cab Scheme(二分图匹配)
题目链接:uva 1201 - Taxi Cab Scheme 建图,X和Y集合均为N个点,如果接完第i个人之后来得及接j,那么从Xi建一条边道Yj。做最大匹配,如果选中Xi到Yj这条边,说明i和j用的是同一辆车,那么需要几辆车即为没有边连入的Y集合点数个数,即为N-最大匹配数。 #include #include #include #include #include原创 2015-09-23 22:11:38 · 729 阅读 · 0 评论 -
uva 1175 - Ladies' Choice(稳定婚姻问题)
题目链接:uva 1175 - Ladies' Choice 稳定婚姻问题裸题。 #include #include #include #include using namespace std; const int maxn = 1005; int N, pref[maxn][maxn], order[maxn][maxn], jump[maxn]; int fut原创 2015-09-23 22:06:05 · 938 阅读 · 0 评论 -
uva 11419 - SAM I AM(最小覆盖)
题目链接:uva 11419 - SAM I AM 行列匹配,对于每个点,所在的行列建一条边,做最大匹配,所选中的边数即为需要的炮数,最后在构造一下输出答案。 #include #include #include #include #include using namespace std; const int maxn = 1005; const int inf =原创 2015-09-23 22:04:04 · 1020 阅读 · 0 评论 -
uva 11383 - Golden Tiger Claw(完美匹配)
题目链接:uva 11383 - Golden Tiger Claw #include #include #include #include using namespace std; const int maxn = 505; const int inf = 0x3f3f3f3f; int N, L[maxn]; int Lx[maxn], Ly[maxn], W[maxn]原创 2015-09-23 21:58:37 · 1103 阅读 · 0 评论 -
uva 10615 - Rooks(完美匹配)
题目链接:uva 10615 - Rooks 显而易见,需要用到颜色种类即为行列中棋子个数的最大值k。问题是如何构造,建图,行和列去匹配,每次匹配一种颜色,将匹配到的边删除即可。需要注意的是,每次需要删除k条边,所以对于度数不足的点需要用无效边凑数,这样保证最后答案可以构造出来。 #include #include #include #include using na原创 2015-09-23 21:55:45 · 1535 阅读 · 0 评论 -
hdu 4619 Warm up 2(KM)
题目链接:hdu 4619 Warm up 2解题思路KM求最大独立集。代码#include <cstdio> #include <cstring> #include <vector> #include <algorithm>using namespace std; const int maxn = 1005;int N, M, L[maxn], X[maxn], Y[maxn]; bool T[m原创 2015-10-26 21:50:17 · 640 阅读 · 0 评论 -
uva 1364 - Knights of the Round Table(二分图+强连通)
题目链接:uva 1364 - Knights of the Round Table 处理出所有点-双联通分量,判断每个联通分量是否是二分图,如果不是二分图的话所有点即为有会议可以参加。 #include #include #include #include #include using namespace std; typedef pair pii; const原创 2015-09-02 23:27:27 · 796 阅读 · 0 评论 -
Codeforces 468B Two Sets(二分图匹配)
题目链接:Codeforces 468B Two Sets 题目大意:给出n个数,要求将n个数分配到两个集合中,集合0中的元素x,要求A-x也再0中,同理1集合。 解题思路:类似二分图匹配的方法。 #include #include #include #include #include using namespace std; const int maxn = 1e5原创 2014-09-25 10:31:11 · 2111 阅读 · 0 评论 -
hdu 5556 Land of Farms(二分图匹配)
题目链接:hdu 5556 Land of Farms解题思路枚举哪些位置是重建的,重建的周围位置不能用,其他空地用做二分图匹配最大独立集。代码#include <cstdio> #include <cstring> #include <cstdlib> #include <vector> #include <algorithm>using namespace std; typedef pair<i原创 2015-11-14 21:22:23 · 1756 阅读 · 0 评论