This repository has been archived on 2022-06-22. You can view files and clone it, but cannot push or open issues or pull requests.
usaco-guide/content/5_Gold/SP.md

62 lines
2.1 KiB
Markdown
Raw Normal View History

2020-06-04 01:42:57 +00:00
---
2020-06-15 23:19:07 +00:00
id: sp
2020-06-22 01:45:24 +00:00
title: "Shortest Paths with Non-Negative Edge Weights"
2020-06-04 01:42:57 +00:00
author: Benjamin Qi
2020-06-05 00:21:03 +00:00
prerequisites:
2020-06-22 20:51:12 +00:00
- Gold - Breadth First Search
2020-06-22 19:59:16 +00:00
description: Introduces Dijkstra's Algorithm for a single source as well as Floyd-Warshall for All-Pairs Shortest Path.
2020-06-04 01:42:57 +00:00
---
2020-06-03 21:08:42 +00:00
## Non-Negative Edge Weights
2020-06-03 20:56:04 +00:00
2020-06-03 21:08:42 +00:00
Use *Dijkstra's Algorithm*.
2020-06-03 20:56:04 +00:00
2020-06-04 21:42:30 +00:00
### Standard
2020-06-03 20:56:04 +00:00
2020-06-04 21:42:30 +00:00
- [Kattis SSSP Non-Negative](https://open.kattis.com/problems/shortestpath1)
- [CSES Shortest Routes I](https://cses.fi/problemset/task/1671)
2020-06-03 20:56:04 +00:00
2020-06-04 21:42:30 +00:00
### Tutorial
2020-06-03 20:56:04 +00:00
2020-06-04 21:42:30 +00:00
- CSES 13.2
2020-06-23 01:00:35 +00:00
- [PAPS 12.3.1](https://www.csc.kth.se/~jsannemo/slask/main.pdf)
2020-06-04 21:42:30 +00:00
- [cp-algo Dijkstra (Dense Graphs)](https://cp-algorithms.com/graph/dijkstra_sparse.html)
- [cp-algo Dijkstra (Sparse Graphs)](https://cp-algorithms.com/graph/dijkstra_sparse.html)
- Usually, it's this one that's applicable.
- [CPC.8](https://github.com/SuprDewd/T-414-AFLV/tree/master/08_graphs_2)
### Problems
- CSES
- [CSES Flight Discount](https://cses.fi/problemset/task/1195)
- [CSES Flight Routes](https://cses.fi/problemset/task/1196)
- [CSES Investigation](https://cses.fi/problemset/task/1202)
- USACO
- [Milk Pumping](http://www.usaco.org/index.php?page=viewproblem2&cpid=969)
- fairly standard application
- [Shortcut](http://usaco.org/index.php?page=viewproblem2&cpid=899)
- [Fine Dining](http://usaco.org/index.php?page=viewproblem2&cpid=861)
- Other
- [Lane Switching](https://open.kattis.com/contests/acpc17open/problems/laneswitching)
- [Robot Turtles](https://open.kattis.com/problems/robotturtles) [](100)
2020-06-03 20:56:04 +00:00
2020-06-03 21:08:42 +00:00
## All Pairs Shortest Path (APSP)
2020-06-03 20:56:04 +00:00
Use the *Floyd-Warshall* algorithm.
2020-06-04 21:42:30 +00:00
### Standard
- [CSES Shortest Routes II](https://cses.fi/problemset/task/1672)
- [Kattis APSP (with negative weights)](https://open.kattis.com/problems/allpairspath)
2020-06-03 21:08:42 +00:00
### Tutorial
2020-06-03 20:56:04 +00:00
2020-06-04 21:42:30 +00:00
- CPH 13.3
2020-06-23 01:00:35 +00:00
- [PAPS 12.3.3](https://www.csc.kth.se/~jsannemo/slask/main.pdf)
2020-06-04 21:42:30 +00:00
- [cp-algo Floyd-Warshall](https://cp-algorithms.com/graph/all-pair-shortest-path-floyd-warshall.html)
2020-06-03 20:56:04 +00:00
2020-06-04 21:42:30 +00:00
### Problems
2020-06-03 20:56:04 +00:00
2020-06-04 21:42:30 +00:00
- [USACO Moortal Cowmbat](http://usaco.org/index.php?page=viewproblem2&cpid=971)
- Use APSP before running DP.
2020-06-22 01:45:24 +00:00
- [SPOJ Arbitrage](https://www.spoj.com/problems/ARBITRAG/)