Implementation problem of the Dijkstra Algorithm

Правка en2, от 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.

Теги graphs, dijkstras validity, dijkstra

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский roycf123 2023-07-24 10:10:22 3435 (published)
en1 Английский roycf123 2023-07-24 10:01:56 2034 Initial revision (saved to drafts)