树剖
Hunter_HunterL
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
约会
题目描述 输入 输出 样例输入 4 1 2 1 3 2 4 1 2 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 · 313 阅读 · 0 评论 -
旅游(国家集训队)
题面 树链剖分,边权存到点上,注意边界处理 #include #include #include #define maxn 100005 using 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 · 324 阅读 · 0 评论
分享