Water in a Tree

Peregrine_Falcon PIHACKS'21-CodeJam

Let the equation for mix water from two nodes aa and bb is Tc=(Ta×Sa+Tb×Sb)/(Sa+Sb)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.

Statistics

75% Solution Ratio
gokul.rajEarliest, Aug '21
merIinFastest, 0.1s
merIinLightest, 21 MB
merIinShortest, 2447B
Toph uses cookies. By continuing you agree to our Cookie Policy.