[题目链接] 点击打开链接 [算法] 树链剖分模板题 [代码] #include<bits/stdc++.h> using namespace std; #define MAXN 30000 struct SegmentTree { int l,r,maxn,sum; } tree[MAXN*]; int i,N,Q,u,v,t,num; ],fa[MAXN+],son[MAXN+],pos[MAXN+], top[MAXN+],dep[MAXN+],id[MAXN+],a[MAXN+]; s…