Chef Travel Routes

Hello Everyone,
I am confused after submitting solution to above problem. After submission it shows wrong answer. I compared my code with the author’s solution. It was exactly same.
Even the output also matched with the sample output.
Please help me in figuring out the reason.

Please post the link to the question and your code as well so that someone can understand where the bug lies in your code and its easier to access the problem.

Thanks Pranjal for replying.
Link to Question is

Answer -