随笔分类 -  图论

摘要:#pragma comment(linker, "/STACK:102400000,102400000") 手动加栈 强连通分量:有向图中两两可达的子图,即环 无向图: 割点:就是删掉这个点之后连通分量增加, 桥:删除这条边后连通分量增加。 边双连通分量:无向图中两两可达的子图,及环。 https: 阅读全文
posted @ 2019-04-16 14:36 downrainsun 阅读(470) 评论(0) 推荐(1)
摘要:https://vjudge.net/contest/295298#problem/A lca 的题目 求任意两点的距离。 A题是在线算法,用st表rmq来实现。 https://blog.csdn.net/nameofcsdn/article/details/52230548 相当于先把整个树df 阅读全文
posted @ 2019-04-15 18:45 downrainsun 阅读(301) 评论(0) 推荐(1)
摘要:https://vjudge.net/contest/286149#problem/G 专题连接 1.判二分图 The Accomodation of Students https://blog.csdn.net/flynn_curry/article/details/52966283 这个讲了最大 阅读全文
posted @ 2019-03-07 16:38 downrainsun 阅读(191) 评论(0) 推荐(1)
摘要:https://vjudge.net/contest/213797#problem/A习题集 求区间最大值 A - 敌兵布阵 HDU - 1166 求区间和。 I Hate It HDU - 1754 区间最大值。 区间修改加区间求和 A Simple Problem with Integers P 阅读全文
posted @ 2019-02-07 23:03 downrainsun 阅读(228) 评论(0) 推荐(1)
摘要:最小生成树,基于并查集,把边权排序,看父节点不相同就连,最大生成树一样的。 https://vjudge.net/contest/280903#problem/A习题集HDu1102 下面是最简单的一种。 Slim Span UVA - 1395 find the most comfortable 阅读全文
posted @ 2019-01-28 17:22 downrainsun 阅读(167) 评论(0) 推荐(1)
摘要:找入度为零的点,然后一个一个存,一般用于很多任务,给出几个优先级, 然后得到总的顺序。 https://vjudge.net/contest/280900#problem/A习题 难题 https://vjudge.net/contest/280900#problem/H Sorting It Al 阅读全文
posted @ 2019-01-27 18:10 downrainsun 阅读(196) 评论(0) 推荐(1)
摘要:.下面是判有没有欧拉路或欧拉回路的,用并查集来做,判断是否联通,注意欧拉回路包括欧拉路。 无向图:回路:所有点度都是偶数,路:起点终点是奇数 有向图:回路:所有点的入度等于出度,路:起点或终点,一个点入度比出度大一,一个点出度比入度大一。 题目:john's trip https://vjudge. 阅读全文
posted @ 2019-01-26 14:18 downrainsun 阅读(217) 评论(0) 推荐(1)
摘要:RMQ的预处理时间复杂度为nlogn,但是查找的话就是线性的。 https://vjudge.net/contest/228508#problem/B 专题连接 https://vjudge.net/contest/228508#problem/A 这一题那个while循环注意看一下。注意下二分区间 阅读全文
posted @ 2019-01-20 18:36 downrainsun 阅读(129) 评论(0) 推荐(1)
摘要:https://blog.csdn.net/hpu2022/article/details/81910490 https://blog.csdn.net/qq_39670434/article/details/78425125 https://www.cnblogs.com/gj-Acit/p/32 阅读全文
posted @ 2019-01-20 11:40 downrainsun 阅读(333) 评论(0) 推荐(1)
摘要:第一种是不优化的dijiesitela算法,用邻接矩阵输入。 https://blog.csdn.net/qq_38367681/article/details/81178337 https://blog.csdn.net/wang_123_zy/article/details/82497369 前 阅读全文
posted @ 2018-10-01 19:27 downrainsun 阅读(568) 评论(0) 推荐(1)
摘要:使用并查集查找时,如果查找次数很多,那么使用朴素版的查找方式肯定要超时。比如,有一百万个元素,每次都从第一百万个开始找,这样一次运算就是10^6,如果程序要求查找个一千万次,这样下来就是10^13,肯定要出问题的。 这是朴素查找的代码,适合数据量不大的 int findx(int x) { int 阅读全文
posted @ 2018-09-30 22:54 downrainsun 阅读(308) 评论(0) 推荐(1)
摘要:遍历所有状态最好用dfs,求最短路用bfs,(无权值,都是一); 要注意满足状态与越界状态。(必要时设标志位) dfs bool judge(){ int k, p, q; for(int i = 0; i < n; i++){ if(b[i] == true) k++; } for(int i = 阅读全文
posted @ 2018-09-30 22:53 downrainsun 阅读(666) 评论(0) 推荐(1)