I have started learning dijkstra algorithm but i can not solve any problem on any ojs. I don't know how to find second shortest path or these kinda problem . I just can figure out shortest path. How can i be an expert on dijkstra algo?
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
I have started learning dijkstra algorithm but i can not solve any problem on any ojs. I don't know how to find second shortest path or these kinda problem . I just can figure out shortest path. How can i be an expert on dijkstra algo?
Название |
---|
Dijkstra finds paths in non-decreasing order of cost. For regular shortest path problems, you do not continue searching paths that aren't the shortest for that vertex, however in second-shortest path you need to keep a counter for how many times a vertex has been dequeued from the priority queue / heap, and continue the search if it's the shortest or second-shortest path.
Do you have the code link?
https://lightoj.com/submission/2300476
Edit: I'm not sure whether you can view this submission, so:
Link to problem: https://lightoj.com/problem/not-the-best
Code (Rust): https://www.toptal.com/developers/hastebin/ifukayaqov.rust
Codeforces graphs and shortest paths tags (Editorial if you can't solve them)
Cses graph problems
Book
get brain (and use it)
Try to understand and challenge each step of algorithm, try to come up with counter examples. Soon you will find out why it actually works and how to extend it to other problems. Post here if you get stuck.
Might as well use the USACO guide. Under the gold section in the Shortest Path with nonnegative weights, there are nice problems from various OIs and OJs with most of them having an internal solution