
图论
文章平均质量分 66
czjxy881
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
zoj 2770 Burn the Linked Camp 差分约束
最近状态太散漫,一天才写了这一题,很基础的差分约束,直接写出关系式即可。注意边数开大点 /* author:jxy lang:C/C++ university:China,Xidian University **If you need to reprint,please indicate the source** */ #include #include #include #i原创 2013-05-16 23:14:58 · 592 阅读 · 0 评论 -
spoj 208 Store-keeper bfs+重联通分量
图论书上的一道练习题,却写了整整一周。 思路很简单,最简单的想法是bfs+dfs,就是没到拐点的时候dfs一次看是否可达,但是必然超时。所以就用重联通分量优化。判断拐点是否为割点,如果是割点,判断两边是否在一个重联通分量中。 一开始一直在考虑如何拐点是割点,两边的点也是不同重连通分量,但是这两个重联通分量并不是由拐点分割的怎么处理,想到了用个链表记录,然后二分判断,但感觉复杂度太原创 2013-09-04 02:06:27 · 725 阅读 · 0 评论 -
poj 2942 Knights of the Round Table 点重联通分量
书上把这放在边联通的第一道题,于是一开始就按边写了,一直写不对,重新想了一遍,才发现是点联通…… /* author:jxy lang:C/C++ university:China,Xidian University **If you need to reprint,please indicate the source** */ #include #include #includ原创 2013-09-13 20:40:10 · 543 阅读 · 0 评论 -
poj 1021 2D-Nim 图论
判断点阵是否是同构,乱搞了个·n^3的方法,就是判断每个点到四周的距离,然后记录下来,排个序,如果两个完全一样则为YES,否则为NO。 应该在dfs上加优化就可以降到n^2.但感觉意义不大 一开始WA了2次,最后发现时结构体的构造函数没有初始化 /* author:jxy lang:C/C++ university:China,Xidian Unkjiversity **If原创 2013-10-01 22:50:12 · 1756 阅读 · 2 评论 -
CF 203 div2 E. Wrong Floyd 图论
题目中只选取k个点更新,因此只要保证有一个点只连到非k点即可 注意:题目要求连通图!!比赛的时候没看到,WA了,只要改下输出顺序即可保证联通。 /* author:jxy lang:C/C++ university:China,Xidian University **If you need to reprint,please indicate the source** */ #in原创 2013-10-02 02:01:24 · 815 阅读 · 0 评论 -
hdu 4750 Count The Pairs 最小生成树
比赛时候水了,一直打算算出22直接的关系数,然后又要考虑图不连通情况等等,搞了半天还没搞定。 其实只要一层一层慢慢加就可以了,最后结果离线或者在线处理一下均可以。 因为最长路的最小值就相当于最小值一个一个添加 贴一下第一个AC队的代码,思路很清晰: #include #include #include using namespace std; typedef原创 2013-09-22 01:04:57 · 734 阅读 · 0 评论 -
hdu 4751 Divide Groups 染色
建个反向图,染个色,一切不言而喻 今天比赛一直把题目想复杂,没改题前先求了重联通图,改题后又试了极大团,2sat等等。还是基础不牢,概念不清 /* author:jxy lang:C/C++ university:China,Xidian University **If you need to reprint,please indicate the source** */ #incl原创 2013-09-22 01:07:59 · 846 阅读 · 0 评论 -
poj 3281 Dinicing
简单建图,source->food->cow1->cow2->drink->collection 一开始数组开小了一直TLE,居然不是RE…… /* author:jxy lang:C/C++ university:China,Xidian University **If you need to reprint,please indicate the source** */ #in原创 2013-10-15 20:06:17 · 584 阅读 · 0 评论 -
uestc 1511 糖果 差分约束
这题时间卡的非常紧,加了一点优化的spfa都会超时……不过用快速读入可以轻松解决时限问题 /* author:jxy lang:C/C++ university:China,Xidian University **If you need to reprint,please indicate the source** */ #include #include #include #in原创 2013-05-31 00:26:55 · 601 阅读 · 0 评论 -
hdu 4707 Pet 水
热身赛就写这一题还读错题意了,以为是求长度为d的最小覆盖集,结果居然是求深度大于d的点数…… /* author:jxy lang:C/C++ university:China,Xidian University **If you need to reprint,please indicate the source** */ #include #include #include #incl原创 2013-09-09 11:30:44 · 710 阅读 · 0 评论 -
zoj 2588 Burning Bridges 边联通性
最基本的找桥,要注意0的情况,不用输出空行,zoj现在真慢 /* author:jxy lang:C/C++ university:China,Xidian University **If you need to reprint,please indicate the source** */ #include #include #include #include #include原创 2013-08-26 23:07:50 · 496 阅读 · 0 评论 -
poj 1201/ZOJ 1508 Intervals 差分约束
典型差分约束,注意一点是可以不把与前后相连的固定边加到图中,直接spfa时判断即可,这样可以节省很多时间空间 差分约束的关键就在于要写清楚不等式 /* author:jxy lang:C/C++ university:China,Xidian University **If you need to reprint,please indicate the source** */ #in原创 2013-05-17 01:13:02 · 573 阅读 · 0 评论 -
poj 3259 Wormholes 最短路
bellman判环即可 /* author:jxy lang:C/C++ university:China,Xidian University **If you need to reprint,please indicate the source** Build Time:2013-05-07-22.01 */ #include #include #include #includ原创 2013-05-08 09:58:28 · 573 阅读 · 0 评论 -
Topcoder 2C 250 最短路
唯一写出来的一题,但也华丽丽地跪了……比赛的时候没有看清可以同时多对一起跳舞,果断跪了 直接先最短路一下,然后除3,因为每3个人才能认识一个新人 #include #include #include #include #include #include #include #include #include #include #include #inclu原创 2013-05-13 00:40:42 · 855 阅读 · 0 评论 -
poj 1613 Cave Raider 最短路
很简单的最短路,只是加上了一定的限制条件。 首先读取时做下处理,把开放时间小于通行时间的去掉。 做最短路的时候判断好逻辑关系即可 注意,这题输入有问题,可能行尾有空格之类的 /* author:jxy lang:C/C++ university:China,Xidian University **If you need to repr原创 2013-05-15 13:57:09 · 928 阅读 · 0 评论 -
cf 274D Lovely Matrix 拓扑排序
直接两两关系必定MLE,所以用增加冗余节点的方法。 另外学习到了个预处理 #pragma comment(linker, "/STACK:1024000000,1024000000") 修改默认栈大小,轻松克服RE /* author:jxy lang:C/C++ university:China,Xidian Universit原创 2013-05-31 00:30:20 · 774 阅读 · 0 评论 -
xdu 1201 An Unfair Game 二分图匹配
将近两个月没写程序了,完全不会写了,一开始居然dfs了一次…… 这其实就是个二分图匹配,只要保证m为最大即可,匈牙利算法 #include #include #include #include using namespace std; int n,m,Max; int map[101][101],q[101]; int vis[101],ok; bool dfs(int now)原创 2013-07-21 20:46:30 · 566 阅读 · 0 评论 -
poj 1144 Network 关节点
Tarjan练手题,WA了两次,处理回边误把low[u]=min(low[u],dph[v]); 写成low[u]=min(low[u],low[v]);了,还要注意节点数小于2时输出0 /* author:jxy lang:C/C++ university:China,Xidian University **If you need to reprint,please indicate the原创 2013-08-20 00:50:24 · 443 阅读 · 0 评论 -
poj 1966 Cable TV Network 点联通度
求点联通度,就是求图中最大独立轨的最小值,把点拆成2个v',v'',v‘->v''容量为1,u-v的一条边就变为u''->v'和v''->u'两个容量为无穷的边,求s‘’ 到e'最大流即可 第一次写dinic,没带当前弧优化,但对这题来说时间已经够了 /* author:jxy lang:C/C++ university:China,Xidian University **If原创 2013-08-19 18:03:39 · 669 阅读 · 0 评论 -
poj 网络流 总结
2112 Optimal Milking 二分+floyd+最大流验证 floyd判断dis=0和t=dis[i][k]+dis[k][j] 顺序错了 WA了好多次 2289 Jamie's Contact Groups 二分+最大流验证 数组开小会TLE,CB 打开-wall 会省去很多debug时间原创 2014-03-14 11:41:07 · 735 阅读 · 0 评论