Propagating tree
HardRating 2000CodeforcesMixed Practice
Approach hintTry it first, then revealHide
Signs alternate with depth, so record an update at x as val times the sign of x on the Euler-tour range of its subtree. A node's value is its initial value plus its own sign times a point query on a range-update Fenwick tree.