
图论
gyarenas
这个作者很懒,什么都没留下…
展开
-
关于有重边图的双连通分量
有向图的的情况比较简单只有一种强连通,重边和连向自己的边对于强连通都没有任何影响无向图的双连通要分点双连通(biconnected)和边双连通(edge_biconnected),连向自己的边对于俩种双连通也没有任何影响,但是重边对点双连通没有影响,但是对于边双连通有影响,因为在求边双连通时,要求对于任意俩点至少存在两条“边不重复”的路径,所以这个时候表示图我们不能用vector了,而是用邻接原创 2013-03-24 12:34:11 · 2653 阅读 · 0 评论 -
无向图中国邮路(小数据版)
http://ac.jobdu.com/problem.php?pid=1430#include #include #include #include #include #include #include #include #include #include #include #include #include #include #inclu原创 2013-11-23 21:14:38 · 1213 阅读 · 0 评论 -
Substitution Cipher spojSCYPHER
http://www.spoj.com/problems/SCYPHER/拓扑排序,要求是全序集#include #include #include #include #include #include #include #include #include #include #include #include #include #include原创 2013-11-24 14:57:14 · 892 阅读 · 0 评论 -
Hard Life poj3155
最大密度子图,论文题目。 这题构造出来的g(k) = max{∑E-k∑V},g(k)是一个下界为0的单调递减函数,即存在x1, g(x1) = 0,对于所有x > x1, g(x)≡0。按照论文上的证明方法的话我们只要发现一个g(k) = 0,就可以认为是最优解了,但是此题要二分到函数值为0的左端点才可以,为什么是这样呢?其实我们不难发现对于所有的x > x1, 我们采取的最优决原创 2013-12-11 21:30:39 · 830 阅读 · 0 评论 -
steiner tree的几道题目
hdu 4085http://acm.hdu.edu.cn/showproblem.php?pid=4085注意森林情况转移时要注意保证每个子森林的房间数等于避难所数#include #include #include #include #include #include #include #include #include #include #include原创 2013-12-09 16:34:14 · 864 阅读 · 0 评论 -
一道有意思最短路
http://codeforces.com/contest/29/problem/E俩个动点的最短路问题,要求俩个点同时移动且不能同时到达在同一点,俩个点要一直移动不能停留等待,求同时到达各自目标点的最短路径。定义状态空间[a][b][c](1#include #include #include #include #include #include #include #i原创 2015-05-04 11:59:02 · 654 阅读 · 0 评论 -
非负权无向图的全局最小割
O(n^3)的StoerWagner算法论文:http://wenku.baidu.com/view/072209d5360cba1aa811da51原创 2015-06-03 15:42:49 · 1207 阅读 · 0 评论 -
最小树形图
Problem DescriptionGiven a weighted digraph GG,a specific vertex v0v_0. Find an arborescence TT with root v0v_0 and minimize the weight sum of arcs of TT.Algorithmhttps://en.wikipedia.org/wiki/Edmonds原创 2016-07-23 12:35:14 · 584 阅读 · 0 评论 -
增加最少的边使有向图变为强连通图
http://codeforces.com/contest/22/problem/E标题党。。。此题是这个问题的简化版本,每个点出度至多为一。先强连通缩点,每个点出度至多为一可以保证从任一个入度为0的点出发只能到达一个出度为0的点 。按标号从第一个入度为0的点a开始,找到其对应的出度为0的点(缩后)a',再找到第二个入度为0的点b,连边a'->b,...,直到最后一个出度为0的点z‘,连边原创 2015-04-30 16:14:11 · 3457 阅读 · 0 评论 -
2-SAT存模板
例题:http://acm.hdu.edu.cn/showproblem.php?pid=3622O(|V||E|)方法#include <cstdio>#include <cstdlib>#include <algorithm>#include <utility>#include <cstring>#include <map>#include <climits>#include <原创 2016-07-04 14:25:40 · 356 阅读 · 0 评论 -
所有边权均不相同的无向图最小生成树是唯一的证明
用反证法,假设G存在俩个不同的最小生成树①.设G的俩个不同的最小生成树T1 T2,设这俩颗生成树的并集为子图G1,G1为连通图且T1 T2显然为G1的最小生成树,将G1中两颗生成树的公共边删去,得到子图G2。G2由一个或多个连通分量组成,其中至少有一个连通分量的最小生成树不唯一(否则若所有连通分量的最小生成树唯一,则将删掉的公共边加上,则T1等于T2,这与假设相矛盾)。②.对其中一个最小生原创 2014-12-29 22:10:39 · 26755 阅读 · 6 评论 -
单点度限制最小生成树存代码
Problem DescriptionGiven a weighted graph GG,a specific vertex v0v_0 and an integer KK, find a spanning tree TT with restriction deg(v0v_0)=KK (we don’t care about other vertices’ degrees) and minimize原创 2016-07-19 16:37:01 · 412 阅读 · 0 评论 -
Dilworth定理与有向无圈图的链覆盖
Dilworth定理的应用条件为偏序集,定理转化为图论语言就是偏序集哈斯图的最长反链等于其最小链点覆盖数。 对于有的问题可以通过贪心分解链求最小链点覆盖或直接求其最大反链长度,从而得出解,例如:俩个全序集的笛卡尔积构成的偏序关系。 例题: http://poj.org/problem?id=1065 http://poj.org/problem?id=1548 http://poj.org原创 2016-11-08 12:00:08 · 1258 阅读 · 0 评论 -
关于图的m着色问题
以前一直以为图的着色问题解等于最大团的顶点数,今天发现原来是有问题的,例如5个顶点的环最大团顶点数为2,但却需要三种颜色。关于m着色问题可以用二分+DLX解决,应该会比爆搜要快。poj 1129#include #include #include #include #include #include #include #include #include #in原创 2013-09-16 20:14:01 · 1387 阅读 · 0 评论 -
【总结】神奇的上下界网络流----- (总结by : becauseofyou)
原文: http://blog.youkuaiyun.com/haha593572013/article/details/8668405犹记得上一年的时候做过上下界网络流的题目,但是那个时候只会套网上的建图方法,对内部的原理一知半解,因此前几天碰到这个题的时候就有些凌乱了,于是,重新学习了下,深刻理解了,估计不会再忘记了,呵呵。好了,言归正传。上下界网络流的话这篇博客写的很转载 2013-07-04 10:27:27 · 5483 阅读 · 0 评论 -
Housewife Wind poj2763
LCA+树状数组,用由于dfs序列中同一子树节点是连续的,所以可以用树状数组维护dfs序列到到根的距离。LCA都忘记咋写了,越来越依赖模板了~~#include #include #include #include #include #include #include #include #include #include #include #includ原创 2013-06-29 21:54:09 · 1029 阅读 · 0 评论 -
Guess LA4255
#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #includ原创 2013-03-21 21:30:41 · 927 阅读 · 0 评论 -
Knights of the Round Table
转化模型为在求一个无向图中不属于任何简单奇圈的点的个数,我们可以求出所有属于简单奇圈的点剩下的点就是答案,首先求在一个简单圈中的点,显然是求点双连通分量(俩个点的点双连通分量不是简单圈,但在后面判断二分图时会把这种情况排除掉),二分图与不存在奇圈的图是等价定义,所以只要在求出点双连通分量后判断每个连通分量是否是二分图(因为如果子原图是二分图,那么其子图必定也是二分图,所以只要判断连通分量是不是二分原创 2013-03-24 21:24:10 · 880 阅读 · 0 评论 -
NOI 06 最大获利
http://www.rqnoj.cn/Problem_556.html题目描述新的技术正冲击着手机通讯市场,对于各大运营商来说,这既是机遇,更是挑战。THU 集团旗下的CS&T 通讯公司在新一代通讯技术血战的前夜,需要做太多的准备工作,仅就站址选择一项,就需要完成前期市场研究、站址勘测、最优化等项目。在前期市场调查和站址勘测之后,公司得到了一共N 个可以作为通讯信号中原创 2012-08-19 10:47:14 · 636 阅读 · 0 评论 -
poj 3621 Sightseeing Cows
Sightseeing CowsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 5767 Accepted: 1901DescriptionFarmer John has decided to reward his cows for their har原创 2012-08-17 15:24:07 · 764 阅读 · 0 评论 -
zoj 2676 Network Wars
Network WarsTime Limit: 5 Seconds Memory Limit: 32768 KB Special JudgeNetwork of Byteland consists of n servers, connected by m optical cables. Each cable connects two servers and ca原创 2012-08-17 22:23:58 · 803 阅读 · 0 评论 -
输出字典序最小的最小割集
USACO 5.4Telecowmunication/*ID: gyarena2PROG: telecowLANG: C++*/char *Task = "telecow";#include <cstdio>#include <cstdlib>#include <string>#include <algorithm>#include <utility>#include <cstri原创 2016-11-10 10:21:44 · 666 阅读 · 0 评论