atcoder#ABC220F. [ABC220F] Distance Sums 2
[ABC220F] Distance Sums 2
Score : points
Problem Statement
Given is a tree with vertices. The vertices are numbered , and the -th edge is an undirected edge connecting Vertices and .
For each integer , find .
Here, denotes the minimum number of edges that must be traversed to go from Vertex to Vertex .
Constraints
- The given graph is a tree.
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print lines.
The -th line should contain .
3
1 2
2 3
3
2
3
We have:
,
,
.
2
1 2
1
1
6
1 6
1 5
1 3
1 4
1 2
5
9
9
9
9
9