I tried many times but am not able to find out the reason for TLE.
Question- https://www.spoj.com/problems/QTREE/
My solution- 0VzhjU - Online C++0x Compiler & Debugging Tool - Ideone.com
I have used the concept of heavy light decomposition.
Plz help me in optimizing my code.