![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
lca
Lyang0.0
这个作者很懒,什么都没留下…
展开
-
F - Nearest Common Ancestors(lca + 树上倍增)
题目链接:https://cn.vjudge.net/problem/POJ-1330A rooted tree is a well-known data structure in computer science and engineering. An example is shown below:In the figure, each node is labeled with an ...原创 2019-08-21 08:38:08 · 162 阅读 · 0 评论 -
P3379 最近公共祖先(LCA 模板)
题目描述如题,给定一棵有根多叉树,请求出指定两个点直接最近的公共祖先。输入格式第一行包含三个正整数N、M、S,分别表示树的结点个数、询问的个数和树根结点的序号。接下来N-1行每行包含两个正整数x、y,表示x结点和y结点之间有一条直接连接的边(数据保证可以构成树)。接下来M行每行包含两个正整数a、b,表示询问a结点和b结点的最近公共祖先。输出格式输出包含M行,每行包含一个...原创 2019-08-16 14:28:30 · 123 阅读 · 0 评论 -
E - How far away ?(lca)
There are n houses in the village and some bidirectional roads connecting them. Every day peole always like to ask like this "How far is it if I want to go from house A to house B"? Usually it hard to...原创 2019-08-16 16:03:52 · 164 阅读 · 0 评论