https://www.codechef.com/viewsolution/39027815 my brute force solution to prove why 1 2 works

But i am not taking same value for each odd level and even level that is the mistake

Before I consider 2 4 6 8 … at even level and 1 3 5 7… at odd but it won’t work then I switch to 3 and 2

Hello, i participated in today’s Cook off challenge. I have a doubt regarding this question (PATHSUMS to be exact) and I’d really appreciate it if someone helped me out.

https://www.codechef.com/viewsolution/39022509

This is my solution, as you can see I’m getting WA. I checkout the editorial, i have used the same approach they have used( assigning a value of 1 to a parent node and 2 to its neighbors and so on), just a different way of representing the tree/graph (In the video they have used adjacency list, I on the other hand have used a vector of pairs)

This is the Editorial/ Youtube Video I’m referring to.

Example Input :

2

7

1 2

4 6

3 5

1 4

7 5

5 1

3

1 2

2 3

Output that I’m getting :

1 2 1 2 2 1 1

1 2 1

Thank You.

https://www.codechef.com/viewsolution/39020002

Can someone tell me why this BFS failed, same approach as editorial, I tried both DFS and BFS but both got wrong

you are not clearing your adj list