so the problem is from cses problem set. Link is https://cses.fi/problemset/task/2134/ Don't know why it is giving Tle. the time complexity of this heavy light decompostion is log2^2(n)*n.Help me guys. And here is my code for this problem https://ideone.com/6Gky4v

Auto comment: topic has been updated by RajiunNabi (previous revision, new revision, compare).It depends on the judge's speed and your constant factor.

~~E.g. an optimized $$$O(nlogn)$$$ will pass but a multiset solution (with $$$O(nlogn)$$$ complexity) won't pass 1926D - Vlad and Division.~~Edit: CSES's judge is slower than CodeForces. Also the multiset TLE isn't about the constant factor, I just checked for existence using`count`

, which is extremely inefficient.dude what are you saying. I don't even use an multiset

I used segment tree and heavy light trick which will get a log(n)^2 * n complexity

log(n)^2*n isn't very fast