![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
树链剖分
cheng__yu_
这个作者很懒,什么都没留下…
展开
-
树链剖分习题 2(提高)
树链剖分Distance on the tree (树剖) Distance on the tree (树剖) 题意:给定一棵树每条边都带有权值,给定 m 个询问查询 u 和 v 的路径上权值小于等于 w 的边的个数 思路:先拆点将边权变为点权,可以离线来做。将点权小于当前询问权值的点,更新到线段树上,然后在查询路径上出现过的点的数量即可。(大于询问权值的点,还没更新上去) #include <bits/stdc++.h> #define ll long long #define ls (rt&原创 2020-07-01 10:53:27 · 117 阅读 · 0 评论 -
树链剖分习题 1(基础)
P3384 【模板】轻重链剖分 链接:https://www.luogu.com.cn/problem/P3384 #include <bits/stdc++.h> #define ll long long #define ls (rt<<1) #define rs (rt<<1|1) using namespace std; const int maxn=1e5+10; int n,m,r,mod; vector<int> e[maxn]; int w[原创 2020-06-29 20:46:43 · 144 阅读 · 0 评论