I am trying to understand the solution of DISHOWN problem through the author's solution. I fully understand the logic through code. But when I was trying to submit the same code it is showing TLE.. Please help. This is my submitted code. I just copied and pasted the author's solution. asked 19 Jul '14, 11:22

U forgot the part where he mentioned path compression heuristics. Path compression is really important in this problem. I had a similar problem during the contest but after applying path compression i got AC :). Hope this helps. U can check my submission if u want pointers on how to implement path compression , altough i would prefer if u googled and learnt it on your own answered 19 Jul '14, 12:06
