Dijkstra Algorithm
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
You are given a directed weighted graph. Find the shortest distance from vertex to vertex .
Input
The first line contains three integers , and , where is the number of vertices in the graph. Each of the following lines contains integers, representing the adjacency matrix of the graph. The integer at the -th row and -th column indicates the weight of the edge from vertex to vertex . A value of means there is no edge between the vertices, while a non-negative value represents the weight of the edge. The main diagonal of the matrix always contains zeros.
Output
Print the shortest distance from vertex to vertex . If there is no path between the two vertices, print .
Examples
Input #1
Answer #1
Submissions 12K
Acceptance rate 37%