You are an owner of a botanica. To design your botanica you have created a tree on the ground having big white color nodes and edges connecting them. Each node has a herb plant in it with takes y amount of water each day.
Q queries are given in the form A B X. you need to water the plants on the route from A to B(inclusive). You have X amount of water. Water is the maximum number of trees that you can water.
(queries are independent of each other)
My idea behind the solution - Decompose the tree. Create persistent segement tree for each chain(key for the segment tree would be y). For Finding the solution. We can do binary search over the chains between A and B over R amount of water supply.