http://acm.fzu.edu.cn/problem.php?pid=2176 Problem 2176 easy problem Accept: 9 Submit: 32Time Limit: 2000 mSec Memory Limit : 32768 KB Problem Description 给定一棵n个节点以1为根的树,初始每个节点的值为0,现在我们要在树上进行一些操作,操作有两种类型. 1 x val 表示对以x为根的子树的每个点进行加权操作(我们定义每个节点的…
Problem Description Coco has a tree, whose vertices are conveniently labeled by 1,2,…,n.There are m chain on the tree, Each chain has a certain weight. Coco would like to pick out some chains any two of which do not share common vertices.Find out t…
Misha and Grisha are funny boys, so they like to use new underground. The underground has n stations connected with n - 1 routes so that each route connects two stations, and it is possible to reach every station from any other. The boys decided to h…
题意比较难理解,就是给你n个点的树,然后给你m个修改操作,每一次修改包括一个点对(x, y),意味着将x到y所有的点权值加一,最后问你整个树上的点权最大是多少. 比较裸的树链剖分了,感谢Haild的讲解. 首先第一遍dfs预处理出size,son(重儿子). 第二遍dfs重编号. 然后线段树就可以了. 感觉就是把一棵树弄成一条一条的链,新奇的hash方法. #include <bits/stdc++.h> #define rep(i, a, b) for (int i = a; i <=…