题目链接 分析:树上的节点祖先与儿子的关系,一般就会想到dfs序.正解就是对树先进行dfs序排列,再将问题转化到树状数组统计个数.应该把节点按照权值从大到小排序,这样对于,就是从小到大的顺序.这样更新树状数组就不会造成计算的混乱了. 多组数据没有每次先清除边我真是太智障了. 代码: /*****************************************************/ //#pragma comment(linker, "/STACK:1024000000,1024000…