Getting WA : KTHPATH

Hi all,
I was trying to solve this problem https://www.codechef.com/problems/KTHPATH and continuously getting WA.I have tried several test cases of my own including test cases that may include single node,skew tree etc but the code seems to give correct answer for all.It will be helpful if anyone can look at the code and suggest some test cases where my code might fail.

My solution https://www.codechef.com/viewsolution/16027037
Thank you

1 Like

Hey @nilotpal9797

The constraints given in the question are N<=10^5 and Q<=N^2. Thus Q can have a value of 10^10. Since in your code you have taken value of Q as int, this might result in integer overflow condition.

@therisingsun Thanks for that overflow concern but still getting WA after converting Q to long long int. :frowning:
Here is the code after converting Q to long long
https://www.codechef.com/viewsolution/16032605