TomDev's blog

By TomDev, history, 3 months ago, In English

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!

Full text and comments »

  • Vote: I like it
  • +4
  • Vote: I do not like it

By TomDev, history, 4 months ago, In English

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

Full text and comments »

  • Vote: I like it
  • -3
  • Vote: I do not like it