I am unable to pass test cases 2 and 5. I tried to debug my code using test case 2 bt as it is very large(90 edges) I am unable to figure out what am I missing. Can I get some simplified version of test case 2 so that I can understand what am I missing.
I am closing this topic as I found out what was the problem.
Hint for those who got stuck in these two test cases:
the triplet U V W is not unique
eg: The network may contain
1 2 100 and 1 2 50
Closing this topic as it has been solved by you yourself. Great job, keep working hard. if its not resolved feel free to un-mark the accepted solution to re-open the topic.