Let the equation for mix water from two nodes $a$ and $b$ is $T_c = (T_a×S_a + T_b×S_b)/(Sa+Sb)$.

We will use the Heavy Light Decomposition algorithm to solve this problem. The algorithm structure is a typical HLD algorithm. For the Segment Tree part, we will save the volume of water in each node and the temperature of the water. While mixing the waters, we will use the equation for mixing the water of two nodes.

Toph uses cookies. By continuing you agree to our Cookie Policy.