![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
树剖
Hunter_HunterL
这个作者很懒,什么都没留下…
展开
-
约会
题目描述输入输出样例输入41 21 32 412 3样例输出1求lca,但是要用树上倍增来求,if(dis&1) return 0;当距离为奇数时,没有地点满足要求,如果lca到两点的距离刚好相等ans=n-sz[fx]-sz[fy]如果到lca的距离不相等,假设x为深度较大的,那么x需要往上爬dis/2-1原创 2017-08-14 06:35:20 · 240 阅读 · 0 评论 -
旅游(国家集训队)
题面树链剖分,边权存到点上,注意边界处理#include#include#include#define maxn 100005using namespace std;int n,m;struct edge{ int to,ne,w; }b[maxn];int k=0,head[maxn];struct tree{ int l,r,mx,mi,sum;原创 2017-08-16 06:06:09 · 259 阅读 · 0 评论