2.6 KiB
2.6 KiB
slug | title | author |
---|---|---|
/gold/sp | Gold - Shortest Path | Benjamin Qi |
Gold - Shortest Path
Author: Benjamin Qi
Breadth First Search
Find the shortest path where all edge weights are 1.
Tutorial
Problems
Non-Negative Edge Weights
- Kattis SSSP Non-Negative
- CSES Shortest Routes I
- CSES Flight Discount
- CSES Flight Routes
- CSES Investigation
Use Dijkstra's Algorithm.
Tutorial
- CSES 13.2
- cp-algo Dijkstra (Dense Graphs)
- cp-algo Dijkstra (Sparse Graphs)
- Usually, it's this one that's applicable.
USACO Gold Problems
- Milk Pumping
- fairly standard application
- Shortcut
- Fine Dining
All Pairs Shortest Path (APSP)
Use the Floyd-Warshall algorithm.
Tutorial
- CSES 13.3
- cp-algo Floyd-Warshall
USACO Gold Problems
- Moortal Cowmbat
- Use APSP before running DP.
Negative Edge Weights
Hasn't appeared in recent USACO Gold as far as I know.
Can also modify Dijkstra's so it works with negative edge weights (but not negative cycles). The same running time bound no longer applies.