![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
二分图
文章平均质量分 78
无敌大饺子
这个作者很懒,什么都没留下…
展开
-
ZOJ 1525 Air Raid(最小路径覆盖)
最小路径覆盖 = 顶点数 - 最大匹配数. 关于hungary算法可以参考http://imlazy.ycool.com/post.1603708.html 什么是二分图,什么是二分图的最大匹配,这些定义我就不讲了,网上随便都找得到。二分图的最大匹配有两种求法,第一种是最大流(我在此假设读者已有网络流的知识);第二种就是我现在要讲的匈牙利算法。这个算法说白了就是最大流的算法,但是它跟据原创 2013-05-07 21:05:01 · 475 阅读 · 0 评论 -
ZOJ 1364 Machine Schedule(二分图最大匹配)
最小顶点覆盖 = 二分图最大匹配 #include #include #include using namespace std; const int maxn = 211; int g[maxn][maxn], n, m, k; char vis[maxn], fa[maxn]; bool dfs(int u){ for (int i = 1; i <= n + m; ++i){原创 2013-05-07 22:44:46 · 458 阅读 · 0 评论 -
ZOJ 1137 Girls and Boys(二分图最大独立集)
二分图的最大独立集=顶点数-二分图的最大匹配数 二分图的最小顶点覆盖=二分图的最大匹配数 二分图的最小路径覆盖=顶点数-二分图的最大匹配数 因为这里用的是拆点的方法把图改造的二分图,所以最后的结果应该是 n - 二分图的最大匹配数/2 #include #include #include using namespace std; const int maxn = 2000; stru原创 2013-05-08 22:25:34 · 661 阅读 · 0 评论 -
ZOJ 1654 Place the Robots(二分图最大匹配)
具体建图思路,是把一有墙隔着的行或列转换成多行或多列,然后建立行和列之间二分图,最后匈牙利算法, 好文章:http://wenku.baidu.com/view/ab32abbec77da26925c5b0f2.html #include #include #include using namespace std; const int maxn = 51; struct edge{ i原创 2013-05-08 17:53:10 · 519 阅读 · 0 评论 -
ZOJ 1002 Fire Net (搜索 || 二分图)
可以把一行分成多行,一列分出多列,然后用行和列坐标之间建二分图,求最大匹配. #include #include #include using namespace std; const int maxn = 40; char grid[5][5]; bool g[maxn][maxn], vis[maxn]; int rg[5][5], cg[5][5], fa[maxn], n, m原创 2013-05-08 21:18:53 · 804 阅读 · 0 评论 -
ZOJ 1157A Plug for UNIX(二分图最大匹配)
建图比较繁琐. 对于每一个adapter(a b) 连接 a -> b一条有向边.就是能把插在a的插座上的电器插到b插座上 然后对每一个插座i进行DFS,把能够到达的插座j标号,意思就是能把插在j的插座上的电器 插到i上. 最后匈牙利算法. #include #include #include #include #include #include using namespace原创 2013-05-09 11:57:01 · 551 阅读 · 0 评论 -
ZOJ 1882 Gopher II(二分图最大匹配)
把每只gopher 和 能在s时间内到达的洞穴连边,然后匈牙利算法就可以了. #include #include #include #include using namespace std; const int maxn = 210; struct edge{ int v, next; }es[maxn * 10]; double x[maxn], y[maxn]; int fa[ma原创 2013-05-09 15:09:06 · 497 阅读 · 0 评论