# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1036255 | Oz121 | Robot (JOI21_ho_t4) | Java | 3040 ms | 165048 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
import java.io.*;
import java.util.*;
public class Main {
public static int num; public static int m;
public static HashMap<Integer, Long>[] costs;
public static void main(String[] args) throws IOException {
BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer l1 = new StringTokenizer(scan.readLine());
num = Integer.parseInt(l1.nextToken()); m = Integer.parseInt(l1.nextToken());
ArrayList<ArrayList<Edge>> adj = new ArrayList<>(); costs = new HashMap[num];
for (int i = 0;i<num;i++) {
adj.add(new ArrayList<>()); costs[i] = new HashMap<>();
}
for (int i = 0;i<m;i++) {
StringTokenizer st = new StringTokenizer(scan.readLine());
int a = Integer.parseInt(st.nextToken())-1; int b = Integer.parseInt(st.nextToken())-1; int c = Integer.parseInt(st.nextToken()); int d = Integer.parseInt(st.nextToken());
adj.get(a).add(new Edge(b,c,d)); adj.get(b).add(new Edge(a,c,d));
costs[a].put(c, costs[a].getOrDefault(c,0L)+d); costs[b].put(c, costs[b].getOrDefault(c,0L)+d);
}
long ans = dijkstra(adj);
if (ans==Long.MAX_VALUE) System.out.println(-1);
else System.out.println(ans);
}
public static long dijkstra (ArrayList<ArrayList<Edge>> adj) {
HashMap<Integer, Long>[][] dis = new HashMap[num][2];
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |