Language: C++

import java.io.*;
import java.util.Arrays;
 
class Main{
 
static final int INF=Integer.MAX_VALUE/2;
static final PrintWriter out=new PrintWriter(System.out);
 
 
static class Edge{
int from;
int to;
int cost;
Edge(int from,int to,int cost){
this.from=from; this.to=to; this.cost=cost;
}
}
 
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int v=Integer.parseInt(line.split(" ")[0]);
int e=Integer.parseInt(line.split(" ")[1]);
int r=Integer.parseInt(line.split(" ")[2]);
Edge[] es=new Edge[e];
int[] d=new int[v];
for(int i=0;i<e;i++){
line=br.readLine();
int s=Integer.parseInt(line.split(" ")[0]);
int t=Integer.parseInt(line.split(" ")[1]);
int c=Integer.parseInt(line.split(" ")[2]);
es[i]=new Edge(s,t,c);
}
BellmanFord(e,r,es,d);
for(int i=0;i<v;i++){
if(d[i]==INF){
out.println("INF");
}
else{
out.println(d[i]);
}
}
out.flush();
}
}
 
private static void BellmanFord(int ee,int r,Edge[] es,int[] d){
Arrays.fill(d,INF);
d[r]=0;
while(true){
boolean update=false;
for(int i=0;i<ee;i++){
Edge e=es[i];
if(d[e.to]>d[e.from]+e.cost){
d[e.to]=d[e.from]+e.cost;
update=true;
}
}
if(!update){
break;
}
}
}
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.io.*;
      | ^~~~~~
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:6:8: error: 'final' does not name a type
    6 | static final int INF=Integer.MAX_VALUE/2;
      |        ^~~~~
a.cc:7:8: error: 'final' does not name a type
    7 | static final PrintWriter out=new PrintWriter(System.out);
      |        ^~~~~
a.cc:17:2: error: expected ';' after class definition
   17 | }
      |  ^
      |  ;
a.cc:10:1: error: a storage class can only be specified for objects and functions
   10 | static class Edge{
      | ^~~~~~
a.cc:19:7: error: expected ':' before 'static'
   19 | public static void main(String[] args) throws IOException{
      |       ^~~~~~~
      |       :
a.cc:19:25: error: 'String' has not been declared
   19 | public static void main(String[] args) throws IOException{
      |                         ^~~~~~
a.cc:19:34: error: expected ',' or '...' before 'args'
   19 | public static void main(String[] args) throws IOException{
      |                                  ^~~~
a.cc:19:38: error: expected ';' at end of member declaration
   19 | public static void main(String[] args) throws IOException{
      |                                      ^
      |                                       ;
a.cc:19:40: error: 'throws' does not name a type
   19 | public static void main(String[] args) throws IOException{
      |                                        ^~~~~~
a.cc:48:8: error: expected ':' before 'static'
   48 | private static void BellmanFord(int ee,int r,Edge[] es,int[] d){
      |        ^~~~~~~
      |        :
a.cc:48:53: error: expected ',' or '...' before 'es'
   48 | private static void BellmanFord(int ee,int r,Edge[] es,int[] d){
      |                                                     ^~
a.cc:65:2: error: expected ';' after class definition
   65 | }
      |  ^
      |  ;
a.cc: In constructor 'Main::Edge::Edge(int, int, int)':
a.cc:15:6: error: request for member 'from' in '(Main::Edge*)this', which is of pointer type 'Main::Edge*' (maybe you meant to use '->' ?)
   15 | this.from=from; this.to=to; this.cost=cost;
      |      ^~~~
a.cc:15:22: error: request for member 'to' in '(Main::Edge*)this', which is of pointer type 'Main::Edge*' (maybe you meant to use '->' ?)
   15 | this.from=from; this.to=to; this.cost=cost;
      |                      ^~
a.cc:15:34: error: request for member 'cost' in '(Main::Edge*)this', which is of pointer type 'Main::Edge*' (maybe you meant to use '->' ?)
   15 | this.from=from; this.to=to; this.cost=cost;
      |                                  ^~~~
a.cc: In static member function 'static void Main::BellmanFord(int, int, Edge*)':
a.cc:49:1: error: 'Arrays' was not declared in this scope
   49 | Arrays.fill(d,INF);
      | ^~~~~~
a.cc:49:13: error: 'd' was not declared in this scope
   49 | Arrays.fill(d,INF);
      |             ^
a.cc:49:15: error: 'INF' was not declared in this scope
   49 | Arrays.fill(d,INF);
      |               ^~~
a.cc:52:1: error: 'boolean' was not declared in this scope; did you mean 'bool'?
   52 | boolean update=false;
      | ^~~~~~~
      | bool
a.cc:54:8: error: 'es' was not declared in this scope; did you mean 'e'?
   54 | Edge e=es[i];
      |        ^~
      |        e
a.cc:55:8: error: 'int Main::Edge::to' is private within this context
   55 | if(d[e.to]>d[e.from]+e.cost){
      |        ^~
a.cc:12:5: note: declared private here
   12 | int to;
      |     ^~
a.cc:55:16: error: 'int Main::Edge::from' is private within this context
   55 | if(d[e.to]>d[e.from]+e.cost){
      |                ^~~~
a.cc:11:5: note: declared private here
   11 | int from;
      |     ^~~~
a.cc:55:24: error: 'int Main::Edge::cost' is private within this context
   55 | if(d[e.to]>d[e.from]+e.cost){
      |                        ^~~~
a.cc:13:5: note: declared private here
   13 | int cost;
      |     ^~~~
a.cc:56:5: error: 'int Main::Edge::to' is private within this context
   56 | d[e.to]=d[e.from]+e.cost;
      |     ^~
a.cc:12:5: note: declared private here
   12 | int to;
      |     ^~
a.cc:56:13: error: 'int Main::Edge::from' is private within this context
   56 | d[e.to]=d[e.from]+e.cost;
      |             ^~~~
a.cc:11:5: note: declared private here
   11 | int from;
      |     ^~~~
a.cc:56:21: error: 'int Main::Edge::cost' is private within this context
   56 | d[e.to]=d[e.from]+e.cost;
      |                     ^~~~
a.cc:13:5: note: declared private here
   13 | int cost;
      |     ^~~~
a.cc:57:1: error: 'update' was not declared in this scope
   57 | update=true;
      | ^~~~~~
a.cc:60:5: error: 'update' was not declared in this scope
   60 | if(!update){
      |     ^~~~~~