import java.util.*; public class Dijkstra { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // read from Standard Input int n = sc.nextInt(); // number of nodes int m = sc.nextInt(); // number of edges int[][] mat = new int[n][n]; // Adjacency matrix of node connections for (int i=0; i0 && !fixed[y]) { // if y is directly connected with x and y is unfixed int d2 = distance[x]+mat[x][y];// calculate distance of y via x // if shorter, update the shortest distance of y if (d2 < distance[y]) distance[y] = d2; } } } } // returns index of minimum distance[] whose fixed[] is false static int minIndex(int[] distance,boolean[] fixed) { int idx = -1; for (int i=0; i distance[i]) idx = i; // index of shortest node } return idx; } }