I have implemented the code to pass the 1st subtask of TREDIFF as explained in the POST CODECHEF DISCUSSION by @rajarshi_basu
Link to the code : Tree Difference - May Lunchtime codechef - Pastebin.com
It is showing WA for both the subtasks
What is wrong in my code? Please tell me ? I was unable to figure out.
I think you are LCA into the list twice. you have to make sure explicitly that you dont do so. I mentioned this in the video as well, you have to take care in order to not include it twice, else ur answer will always be 0.
I have handled it by popping back one element after the loop ends. Should I maintain a set of vertices and check whether it is already present in the set or not?
@rajarshi_basu Thanks a lot! After using set, i am able to get partially correct answer. However, after using counting sort i am still getting TLE for subtask 2.
Link to the modified code: Tree Difference - May Lunchtime codechef - Pastebin.com