问题 B: Tree Climber

内存限制:1024 MB 时间限制:5 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:2 通过:1

题目描述

链接:https://ac.nowcoder.com/acm/contest/57361/B
来源:牛客网
Given a rooted tree with nnn nodes. Each edge has a weight and initially all weights are 000.
You need to perform mmm operations. In each operation you are given three integers l,r,xl,r,xl,r,x, which means you need to find the smallest connected component in the tree that contains all nodes in the range [l,r][l,r][l,r], and add xxx to the weights of edges in this connected component.
After all operations are performed, output the weights of all edges.

输入格式

The first line contains two integers n,mn,mn,m.
The following n−1n-1n1 lines each contain two integers u,vu,vu,v representing that there's an edge between uuu and vvv on the tree.
The following $m$ lines each contains three integers l,r,xl,r,xl,r,x representing an operation.

输出格式

Output n−1n-1n1 lines. The iii-th line contains an integer representing the final weight of the iii-th edge in the input order.

输入样例 复制

6 3
1 2
1 3
2 4
2 5
5 6
3 5 1
4 6 10
1 2 100

输出样例 复制

101
1
11
11
10

数据范围与提示

For the first operation, the smallest connected component contains vertices 1,2,3,4,5.
For the second operation, the smallest connected component contains vertices 2,4,5,6.
For the third operation, the smallest connected component contains vertices 1,2.