WA IN HOMEDEL

Can someone please point out the error in this code HOMDEL Problem - CodeChef

Here is my solution: KNrzmr - Online C++ Compiler & Debugging Tool - Ideone.com

I am basically using Dijkstra’s algorithm precomputing the distances for every possible source and destination node.