![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法_最近公共祖先
文章平均质量分 79
wang2147483647
这个作者很懒,什么都没留下…
展开
-
UVAlive 6622 Absurdistan Roads(最小生成树+LCA)
题目地址:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4633思路:每个点之间连边,权值为两点之间的最短距离。则该图的最小生成树的n-1条边在最终的n条边内。则两点(i,j)之间距离为dist[i]+dist[j]-2*dist[ L原创 2016-08-20 19:26:33 · 644 阅读 · 0 评论 -
Gym 100685G Gadget Hackwrench(LCA)
题目地址:http://codeforces.com/gym/100685/problem/G思路:不考虑方向,则#include#include#include#include#include#include#define debuusing namespace std;const int maxn=1e5+50;struct Node{ int p,id;原创 2016-08-31 16:08:15 · 586 阅读 · 0 评论 -
Hdu 3686 Traffic Real Time Query System(双联通分量+LCA)
题目地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=3686思路:对于两条边, 若其在同一双联通分量中,则它们最少有两条路可达。所以从边x--->y,必须经过的点的数目为从x所在双连通分量到y所在双连通分量的割点的数目。则找出所有双连通分量,缩成一点,构成双连通分量---割点----双连通分量。。。。。则缩完点后,新图构成一棵树,则必须经过原创 2016-09-01 17:09:03 · 565 阅读 · 0 评论