Submit solution

Points:
7

Time limit:
1.0s

Memory limit:
256M

Author:

Problem type

Allowed languages

Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, ~~CommonLisp~~, D, Dart, F#, Forth, Fortran, Go, ~~Groovy~~, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, ~~Nim~~, ~~ObjC~~, OCaml, ~~Octave~~, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

##### Problem Description

Solve the Single Source Shortest Path problem.

#### Input Specification

Line : (vertices), (bidirectional edges)

Lines to : , a bidirectional edge from to with weight . Multiple edges between the same pair of vertices may occur in the input.

#### Output Specification

Lines to : line has the length of the shortest path from vertex to vertex . If no path exists, output `-1`

.

#### Sample Input

```
4 3
1 2 2
1 3 5
2 3 2
```

#### Sample Output

```
0
2
4
-1
```

## Comments

Like how are the nodes linked?

thank you!

This comment is hidden due to too much negative feedback. Click here to view it.

Is there something wrong with my implementations of Dijkstra's? How come Bellman-Ford is two times faster?

Can someone please tell me what is wrong with my c++ code? I just translated my Python Code, which passed with AC, into a c++ one, but it gets the majority of the cases wrong. Thanks in advance.

Your C++ code is quite different from your Python code. Please reread the problem description.

I am actually dumb, I forgot that "Multiple edges between the same pair of vertices may occur in the input." Thanks for the reply.

.

So, undirected.

thanks

This comment is hidden due to too much negative feedback. Click here to view it.