INOI1402 - code isnt working

I have used the floyd warshall algorithm . I cant figure out whats wrong in the code. The output is a very large number

Code : https://www.codechef.com/viewsolution/19069414

I have made changes according to the undirected nature of graph ie graph[y][x]=p ; Still not working .