help in a march long question!

I had tried to solve the challenge question of this month long. my submission : CodeChef: Practical coding for everyone (upd)

I know it is not optimized but can someone please provide some test where my code fails(as it is giving WA).

2nd update


Try this input

6
1 2 1
1 3 1
1 4 999
3 5 1
3 6 1

and your output will be

1 -10
0 -9
1 -9
3 989
1 -8
2 -8

Now edge 1-4 is clashing with edge 3-6.

Old initial answer


Try this input

4
1 2 9
1 3 1
3 4 9

Your output will be

2 -10
0 -1
1 -9
1 0

Edge 1-2 clashes with edge 3-4.

1 Like

thanks for this! but it is still showing WA : CodeChef: Practical coding for everyone

@pk301 I have updated my answer.