Comments

two color wont work. Try:-

4
100 1 2 200
1 2
2 3
3 4

Thanks, that clears it

That's what i tried, not sure why it was wrong 270739384

Same problem for me, wrong ans for test case 4. And I'm getting the same result at you (1 4 1 1) for the above test case. Did you find a solution for it yet?