Hi, I was trying to solve this problem GOT . My idea was to apply Heavy Light Decomposition on Tree with Segment Tree where each node of Segment Tree stores a std::set. Complexity of each query is O(LOGN * LOGN) which gives, TLE .
So, Any Hints on how to improve the solution.
Thanks