COMRADES Problem

i have spent days thinking about this question and still no where near to the solution
please give me a hint as to how to solve this problem
or an insight into the approach

its a very good question.
think about the folowing steps-

  1. flat the tree using timein and timeout.
  2. now for every node to update the tree , apply a range update query with lazy propagation from from timein[cur] to timeout[cur].
    and quesr.
    you will understand this after studying about flattening the tree

sir, i dont know what u mean by flattening the tree by timein and timeout
its not in the course

https://codeforces.com/blog/entry/63117
watch this blog, it even has a video and then comment again