WA in DISHOWN

I was solving this question but I am getting WA.
Can someone point where I am going wrong or any test case where i am getting WA
Here is my link to the code.

Your code is almost correct. There is just one small logical error while comparing scores. You want to compare scores of owners of x and y and not scores of x and y. I hope this answers your query. Also this code should give tle after it passes the WA test case. You should update the owners on your way as it will decrease the levels in the tree.

for example: say this is the scenario

                owner of 3 = 2 and onwer of 2 = 1 and owner of 1  = 1

                This implies there is a chain 1->2->3. You can make it some thing like  

                    1

                 /    \

               2        3
 Refer to http://www.codechef.com/viewsolution/4279768 for implementation details.
1 Like

thanks for your reply…i will look into it