Блог пользователя TomDev

Автор TomDev, история, 3 месяца назад, По-английски

I had checked on some websites and they said that when Dijkstra went through a node, it marked that node as optimized and never visit again. But now, I implement Dijkstra with priority queue and compare by checking if distance[v] > distance[u] + w. By that way, it will just get the most optimized way for a node without getting trouble with negative weights.

Here's an example of my Dijkstra code to attempt High Score problem on CSES. My code uses Dijkstra to find the optimal path to the final path and also using the SPFA's trick (count if node is visited more than n times).

My code got Accepted on most of the testcases (except the only one testcase that got Wrong Answer because it detects the wrong cycle — and I don't know why)

My attempt's verdict

Can someone help me explain this? I know that I'm wrong somewhere but I'm so confused. Thank you!

Полный текст и комментарии »

  • Проголосовать: нравится
  • +4
  • Проголосовать: не нравится

Автор TomDev, история, 4 месяца назад, По-английски

Today, I decided to share my repository of my source codes on OJs — where I store and arrange my solutions: CP-Archive.

Disclaimer: This is a personal progress tracker, not a formal encyclopedia. Read at your own risk!

Quick Links:

Repo preview

Полный текст и комментарии »

  • Проголосовать: нравится
  • -3
  • Проголосовать: не нравится