TREDIFF WA for Subtask 1

Problem Link - https://www.codechef.com/problems/TREDIFF
Can any1 tell whats wrong with my code? I use simple DFS and store path in a vector. Then I calculate the minimum among them . It should pass Subtask 1 .But its giving WA
https://www.codechef.com/viewsolution/33513447

You are not clearing adj vector after each TC
Try-
2
6 3
10 2 5 6 5 6
1 2
2 3
2 4
1 5
5 6
5 6
3 5
1 4

6 3
10 2 5 6 5 6
1 2
2 3
2 4
1 5
5 6
5 6
3 5
1 4

3 Likes

Thanks for pointing it out. So silly of me :sleepy:

I also made the same mistake and it took more than hour to find it. Finally @ssjgz helped me. A lot of people have made the same mistake.