import java.io.*; import java.util.*; public class HubDriving { public static void main(String[] argv){ Scanner in = new Scanner(System.in); int nCases = in.nextInt(); for(int i=0;i costs = new TreeSet(); nodes[source].cost = 0; costs.add(nodes[source]); while(costs.size()>0){ Node n = costs.first(); costs.remove(n); pathcost[n.name] = n.cost; for(Edge e : n.edges){ Node other = e.a==n?e.b:e.a; if(n.cost+e.weight < other.cost){ costs.remove(other); other.cost = n.cost+e.weight; costs.add(other); } } } return pathcost; } } class Node implements Comparable{ Integer name; int cost; HashSet edges = new HashSet(); Node(Integer name){ this.name = name; } // consistent with equals for TreeSet public int compareTo(Node o){ if(cost!=o.cost) return cost - o.cost; else return name.compareTo(o.name); } public String toString(){ return "Node:"+name; } public int hashCode(){ return name.hashCode(); } } class Edge implements Comparable { Node a; Node b; int weight; Edge(Node a, Node b, int weight){ this.a = a; this.b = b; this.weight = weight; a.edges.add(this); b.edges.add(this); } public int compareTo(Edge o){ return weight - o.weight; } public String toString(){ return a.name+"--"+b.name+"("+weight+")"; } }