Language: C++

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;



class Dijkstra{
    class Edge{
        int to,cost;
        Edge(int to,int cost){this.to=to;this.cost=cost;}
    }
    class Node{
        int v,dis;
        Node(int v,int dis){this.v=v;this.dis=dis;}
    }
    List<Edge> edges[];
    int[] d;
    void add_edge(int from,int to,int cost){
        edges[from].add(new Edge(to,cost));
    }
    Dijkstra(int N){
        edges = new ArrayList[N];
        d = new int[N];
        for(int i=0;i<N;++i)edges[i]=new ArrayList<>();
    }
    Dijkstra(int N,int[] from, int[] to,int[] cost){
        edges = new ArrayList[N];
        d = new int[N];
        for(int i=0;i<N;++i)edges[i]=new ArrayList<>();
        for(int i=0;i<from.length;++i)edges[from[i]].add(new Edge(to[i],cost[i]));
    }

    int shortest(int s,int t){
        Arrays.fill(d, Integer.MAX_VALUE);
        d[s]=0;
        PriorityQueue<Node> que = new PriorityQueue<>((a,b)->a.dis-b.dis);
        que.add(new Node(s,0));
        while(!que.isEmpty()){
            Node node = que.poll();
            if(node.dis > d[node.v])continue;
            for(Edge e : edges[node.v]){
                if(d[e.to]<=d[node.v]+e.cost)continue;
                d[e.to]=d[node.v]+e.cost;
                que.add(new Node(e.to, d[e.to]));
            }
        }
        return d[t];
    }



    // AIZU ONLINE JUDGE
    // 単一始点最短経路
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int V = scan.nextInt();
        int E = scan.nextInt();
        int s = scan.nextInt();
        int[] from = new int[E];
        int[] to = new int[E];
        int[] c = new int[E];
        for(int i=0;i<E;++i){
            from[i]=scan.nextInt();
            to[i]=scan.nextInt();
            c[i]=scan.nextInt();
        }
        Dijkstra dijkstra = new Dijkstra(V, from, to, c);
        dijkstra.shortest(s, 0);
        for(int i=0;i<V;++i)System.out.println((dijkstra.d[i]<Integer.MAX_VALUE ? String.valueOf(dijkstra.d[i]):"INF"));
    }

}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.ArrayList;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.Arrays;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.List;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import java.util.PriorityQueue;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
    5 | import java.util.Scanner;
      | ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:13:6: error: expected ';' after class definition
   13 |     }
      |      ^
      |      ;
a.cc:18:5: error: expected ';' at end of member declaration
   18 |     List<Edge> edges[];
      |     ^~~~
      |         ;
a.cc:18:9: error: expected unqualified-id before '<' token
   18 |     List<Edge> edges[];
      |         ^
a.cc:19:8: error: expected unqualified-id before '[' token
   19 |     int[] d;
      |        ^
a.cc:28:26: error: expected ',' or '...' before 'from'
   28 |     Dijkstra(int N,int[] from, int[] to,int[] cost){
      |                          ^~~~
a.cc:56:11: error: expected ':' before 'static'
   56 |     public static void main(String[] args){
      |           ^~~~~~~
      |           :
a.cc:56:29: error: 'String' has not been declared
   56 |     public static void main(String[] args){
      |                             ^~~~~~
a.cc:56:38: error: expected ',' or '...' before 'args'
   56 |     public static void main(String[] args){
      |                                      ^~~~
a.cc:74:2: error: expected ';' after class definition
   74 | }
      |  ^
      |  ;
a.cc: In constructor 'Dijkstra::Edge::Edge(int, int)':
a.cc:12:36: error: request for member 'to' in '(Dijkstra::Edge*)this', which is of pointer type 'Dijkstra::Edge*' (maybe you meant to use '->' ?)
   12 |         Edge(int to,int cost){this.to=to;this.cost=cost;}
      |                                    ^~
a.cc:12:47: error: request for member 'cost' in '(Dijkstra::Edge*)this', which is of pointer type 'Dijkstra::Edge*' (maybe you meant to use '->' ?)
   12 |         Edge(int to,int cost){this.to=to;this.cost=cost;}
      |                                               ^~~~
a.cc: In constructor 'Dijkstra::Node::Node(int, int)':
a.cc:16:34: error: request for member 'v' in '(Dijkstra::Node*)this', which is of pointer type 'Dijkstra::Node*' (maybe you meant to use '->' ?)
   16 |         Node(int v,int dis){this.v=v;this.dis=dis;}
      |                                  ^
a.cc:16:43: error: request for member 'dis' in '(Dijkstra::Node*)this', which is of pointer type 'Dijkstra::Node*' (maybe you meant to use '->' ?)
   16 |         Node(int v,int dis){this.v=v;this.dis=dis;}
      |                                           ^~~
a.cc: In member function 'void Dijkstra::add_edge(int, int, int)':
a.cc:21:9: error: 'edges' was not declared in this scope
   21 |         edges[from].add(new Edge(to,cost));
      |         ^~~~~
a.cc:21:41: error: 'Dijkstra::Edge::Edge(int, int)' is private within this context
   21 |         edges[from].add(new Edge(to,cost));
      |                                         ^
a.cc:12:9: note: declared private here
   12 |         Edge(int to,int cost){this.to=to;this.cost=cost;}
      |         ^~~~
a.cc: In constructor 'Dijkstra::Dijkstra(int)':
a.cc:23:20: error: no matching function for call to 'Dijkstra::Node::Node()'
   23 |     Dijkstra(int N){
      |                    ^
a.cc:16:9: note: candidate: 'Dijkstra::Node::Node(int, int)'
   16 |         Node(int v,int dis){this.v=v;this.dis=dis;}
      |         ^~~~
a.cc:16:9: note:   candidate expects 2 arguments, 0 provided
a.cc:14:11: note: candidate: 'constexpr Dijkstra::Node::Node(const Dijkstra::Node&)'
   14 |     class Node{
      |           ^~~~
a.cc:14:11: note:   candidate expects 1 argument, 0 provided
a.cc:14:11: note: candidate: 'constexpr Dijkstra::Node::Node(Dijkstra::Node&&)'
a.cc:14:11: note:   candidate expects 1 argument, 0 provided
a.cc:24:9: error: 'edges' was not declared in this scope
   24 |         edges = new ArrayList[N];
      |         ^~~~~
a.cc:24:21: error: 'ArrayList' does not name a type
   24 |         edges = new ArrayList[N];
      |                     ^~~~~~~~~
a.cc:25:9: error: 'd' was not declared in this scope
   25 |         d = new int[N];
      |         ^
a.cc:26:42: error: 'ArrayList' does not name a type
   26 |         for(int i=0;i<N;++i)edges[i]=new ArrayList<>();
      |                                          ^~~~~~~~~
a.cc:26:52: error: expected primary-expression before '>' token
   26 |         for(int i=0;i<N;++i)edges[i]=new ArrayList<>();
      |                                                    ^
a.cc:26:54: error: expected primary-expression before ')' token
   26 |         for(int i=0;i<N;++i)edges[i]=new ArrayList<>();
      |                                                      ^
a.cc: In constructor 'Dijkstra::Dijkstra(int, int*)':
a.cc:28:52: error: no matching function for call to 'Dijkstra::Node::Node()'
   28 |     Dijkstra(int N,int[] from, int[] to,int[] cost){
      |                                                    ^
a.cc:16:9: note: candidate: 'Dijkstra::Node::Node(int, int)'
   16 |         Node(int v,int dis){this.v=v;this.dis=dis;}
      |         ^~~~
a.cc:16:9: note:   candidate expects 2 arguments, 0 provided
a.cc:14:11: note: candidate: 'constexpr Dijkstra::Node::Node(const Dijkstra::Node&)'
   14 |     class Node{
      |           ^~~~
a.cc:14:11: note:   candidate expects 1 argument, 0 provided
a.cc:14:11: note: candidate: 'constexpr Dijkstra::Node::Node(Dijkstra::Node&&)'
a.cc:14:11: note:   candidate expects 1 argument, 0 provided
a.cc:29:9: error: 'edges' was not declared in this scope
   29 |         edges = new ArrayList[N];
      |         ^~~~~
a.cc:29:21: error: 'ArrayList' does not name a type
   29 |         edges = new ArrayList[N];
      |                     ^~~~~~~~~
a.cc:30:9: error: 'd' was not declared in this scope
   30 |         d = new int[N];
      |         ^
a.cc:31:42: error: 'ArrayList' does not name a type
   31 |         for(int i=0;i<N;++i)edges[i]=new ArrayList<>();
      |                                          ^~~~~~~~~
a.cc:31:52: error: expected primary-expression before '>' token
   31 |         for(int i=0;i<N;++i)edges[i]=new ArrayList<>();
      |                                                    ^
a.cc:31:54: error: expected primary-expression before ')' token
   31 |         for(int i=0;i<N;++i)edges[i]=new ArrayList<>();
      |                                                      ^
a.cc:32:23: error: 'from' was not declared in this scope
   32 |         for(int i=0;i<from.length;++i)edges[from[i]].add(new Edge(to[i],cost[i]));
      |                       ^~~~
a.cc:32:67: error: 'to' was not declared in this scope
   32 |         for(int i=0;i<from.length;++i)edges[from[i]].add(new Edge(to[i],cost[i]));
      |                                                                   ^~
a.cc:32:73: error: 'cost' was not declared in this scope; did you mean 'const'?
   32 |         for(int i=0;i<from.length;++i)edges[from[i]].add(new Edge(to[i],cost[i]));
      |                                                                         ^~~~
      |                                                                         const
a.cc: In member function 'int Dijkstra::shortest(int, int)':
a.cc:36:9: error: 'Arrays' was not declared in this scope
   36 |         Arrays.fill(d, Integer.MAX_VALUE);
      |         ^~~~~~
a.cc:36:21: error: 'd' was not declared in this scope
   36 |         Arrays.fill(d, Integer.MAX_VALUE);
      |                     ^
a.cc:36:24: error: 'Integer' was not declared in this scope
   36 |         Arrays.fill(d, Integer.MAX_VALUE);
      |                        ^~~~~~~
a.cc:38:9: error: 'PriorityQueue' was not declared in this scope
   38 |         PriorityQueue<Node> que = new PriorityQueue<>((a,b)->a.dis-b.dis);
      |         ^~~~~~~~~~~~~
a.cc:38:27: error: expected primary-expression before '>' token
   38 |         PriorityQueue<Node> que = new PriorityQueue<>((a,b)->a.dis-b.dis);
      |                           ^
a.cc:38:29: error: 'que' was not declared in this scope
   38 |         PriorityQueue<Node> que = new PriorityQueue<>((a,b)->a.dis-b.dis);
      |                             ^~~
a.cc:38:39: error: 'PriorityQueue' does not name a type
   38 |         PriorityQueue<Node> que = new PriorityQueue<>((a,b)->a.dis-b.dis);
      |                                       ^~~~~~~~~~~~~
a.cc:38:53: error: expected primary-expression before '>' token
   38 |         PriorityQueue<Node> que = new PriorityQueue<>((a,b)->a.dis-b.dis);
      |                                                     ^
a.cc:38:56: error: 'a' was not declared in this scope
   38 |         PriorityQueue<Node> que = new PriorityQueue<>((a,b)->a.dis-b.dis);
      |                                                        ^
a.cc:38:58: error: 'b' was not declared in this scope
   38 |         PriorityQueue<Node> que = new PriorityQueue<>((a,b)->a.dis-b.dis);
      |                                                          ^
a.cc:39:29: error: 'Dijkstra::Node::Node(int, int)' is private within this context
   39 |         que.add(new Node(s,0));
      |                             ^
a.cc:16:9: note: declared private here
   16 |         Node(int v,int dis){this.v=v;this.dis=dis;}
      |         ^~~~
a.cc:42:21: error: 'int Dijkstra::Node::dis' is private within this context
   42 |             if(node.dis > d[node.v])continue;
      |                     ^~~
a.cc:15:15: note: declared private here
   15 |         int v,dis;
      |               ^~~
a.cc:42:34: error: 'int Dijkstra::Node::v' is private within this context
   42 |             if(node.dis > d[node.v])continue;
      |                                  ^
a.cc:15:13: note: declared pri