![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
lca
箱@子
这个作者很懒,什么都没留下…
展开
-
CodeForces - 1304E H - 1-Trees and Queries (LCA)
Gildong was hiking a mountain, walking by millions of trees. Inspired by them, he suddenly came up with an interesting idea for trees in data structures:What if we add another edge in a tree? Then h...原创 2020-02-17 10:41:26 · 289 阅读 · 0 评论 -
HDU - 2586 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-10-17 20:33:04 · 92 阅读 · 0 评论 -
P3379 【模板】最近公共祖先(LCA)(2) ST表法
输入 #1复制 5 5 4 3 1 2 4 5 1 1 4 2 4 3 2 3 5 1 2 4 5 输出 #1复制 4 4 1 4 4 对其进行欧拉排序取区间最小深度 #include<bits/stdc++.h> const int maxn = 5e5 + 10; int n, m, s; int cnt; int tot; int head[maxn]; ...原创 2019-10-16 11:42:07 · 116 阅读 · 0 评论 -
P3379 【模板】最近公共祖先(LCA)(1)倍增法
输入 #1复制 5 5 4 3 1 2 4 5 1 1 4 2 4 3 2 3 5 1 2 4 5 输出 #1复制 4 4 1 4 4 倍增求lca 做法和rmq类似 #include<bits/stdc++.h> const int maxn = 5e5 + 10; int n, m, s; int tot; int head[maxn]; int depth...原创 2019-10-14 11:30:07 · 133 阅读 · 0 评论