将树通过树链剖分转化成线性序列,用线段树维护最值,和值即可。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 using namespace std; 6 const int maxn=30005; 7 int n,m; 8 int head[maxn],to[maxn<<1],nxt[maxn
专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]
Copyright (C)ICode9.com, All Rights Reserved.
ICode9版权所有