The problem statement is simple. You are given a rooted tree (
$1$ is the root) and every node has a cost, say
$C_i$. You have to perform
$Q$ operations. Each operation can be one of the following types.
This is a companion discussion topic for the original entry at https://toph.co/p/yet-another-xinversion