Implementation problem of the Dijkstra Algorithm

Revision en2, by roycf123, 2023-07-24 10:10:22

Recently, I was solving the Graphs section of the CSES problemset and encountered this problem. I used dijkstra algorithm to solve it.

I generally use the template from here, but in this question, this implementation gave me WA. When I used another implementation using visited array, it gave AC.

WA code
AC Code

Naturally, I adopted the visited array approach and discarded the one before.

Now, using the visited array approach on this, I encountered WA again.

WA Code

Now I am very confused about what template to use for dijkstra, being a newbie to graphs. I would highly appreciate if someone helps.

Tags graphs, dijkstras validity, dijkstra

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English roycf123 2023-07-24 10:10:22 3435 (published)
en1 English roycf123 2023-07-24 10:01:56 2034 Initial revision (saved to drafts)