Recently I came accross a problem called Gravity Tree I couldn't solve it on my own so I checked the editorial. The authors solution was to dfs over the vertices once and form a segment tree.where each node contains the distance from the vertice to the centre. Then he mentions a second dfs(I don't know what that's doing. I tried printing his data structures, but they totally don't make sense.without knowing what's actually he's trying to do). The language in which he had written was a bit too hard to grasp. I know What are segment trees,dfs,lazy propogation. But I am not able to wrap my head around this solution. And not knowing the solution makes me very anxious and I am not able to concentrate on other things. It would be nice if someone could give a clearer explanation. So that even others who are confused are benifited . thanks in advance :)
The problem setter is adamant.