import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.NoSuchElementException; import java.util.PriorityQueue; class Edge{ int dst; long cost; public Edge(int dst,long cost) { this.dst=dst; this.cost=cost; } } public class Main { public static void main(String[] args) throws FileNotFoundException { long t = System.currentTimeMillis(); new Main().run(); System.err.println(System.currentTimeMillis() - t); } long[] shortest_path(int src,ArrayList[] g) { long[] dp=new long[g.length]; long INF=Long.MAX_VALUE/3; Arrays.fill(dp, INF); dp[src]=0; class S implements Comparable{ int v; long d; public S(int v,long d) { this.v=v; this.d=d; } public int compareTo(S o) { return Long.compare(d, o.d); }; } PriorityQueue pq=new PriorityQueue<>(); pq.add(new S(src, 0)); while(!pq.isEmpty()) { S s=pq.poll(); if(dp[s.v][] g=new ArrayList[N]; for(int i=0;i(); for(int i=0;i