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/6_Plat/SPneg.mdx

68 lines
2.4 KiB
Text
Raw Normal View History

2020-06-22 01:45:24 +00:00
---
id: sp-neg
title: "Shortest Paths with Negative Edge Weights"
author: Benjamin Qi
prerequisites:
2020-06-22 20:51:12 +00:00
- Gold - Shortest Paths with Non-Negative Edge Weights
2020-06-22 19:59:16 +00:00
description: Applications of Bellman-Ford.
2020-06-28 02:11:09 +00:00
frequency: 0
2020-06-22 01:45:24 +00:00
---
2020-06-28 02:11:09 +00:00
import { Problem } from "../models";
export const metadata = {
problems: {
2020-06-28 03:56:39 +00:00
sam: [
new Problem("Kattis", "SSSP Negative", "shortestpath3", "Easy", false, [], ""),
new Problem("Kattis", "APSP (with negative weights)", "allpairspath", "Easy", false, [], ""),
new Problem("CSES", "(Negative) Cycle Finding", "1197", "Easy", false, [], ""),
],
probs: [
new Problem("SPOJ", "Arbitrage", "ARBITRAG", "Easy", false, [], ""),
new Problem("CSES", "High Score", "1673", "Easy", false, [], ""),
],
2020-06-28 02:11:09 +00:00
linear: [
new Problem("ojuz", "Restore Array", "RMI19_restore", "Normal", false, [], "similar to [Art](https://codeforces.com/gym/102394/problem/A)"),
],
}
};
2020-06-22 01:45:24 +00:00
2020-06-28 03:56:39 +00:00
<problems-list problems={metadata.problems.sam} />
<br/>
2020-06-22 01:45:24 +00:00
### Tutorial
2020-06-28 03:56:39 +00:00
2020-06-28 02:11:09 +00:00
<resources title="SSSP Negative">
<resource source="CPH" title="13.1"></resource>
<resource source="cp-algo" title="Bellman-Ford" url="graph/bellman_ford.html"></resource>
<resource source="cp-algo" title="Finding Negative Cycle" url="finding-negative-cycle-in-graph.html"></resource>
<resource source="TC" title="Intro to Graphs Section 3" url="introduction-to-graphs-and-their-data-structures-section-3/"></resource>
</resources>
Can also use [Shortest Path Faster Algorithm](https://en.wikipedia.org/wiki/Shortest_Path_Faster_Algorithm) or modify Dijkstra slightly (though the same running time bound no longer applies).
(code)?
2020-06-22 01:45:24 +00:00
2020-06-22 14:26:06 +00:00
### Problems
2020-06-28 03:56:39 +00:00
<problems-list problems={metadata.problems.probs} />
2020-06-22 14:26:06 +00:00
## Simple Linear Programming
2020-06-28 02:11:09 +00:00
You can also use shortest path algorithms to solve the following problem (a very simple [linear program](https://en.wikipedia.org/wiki/Linear_programming)).
2020-06-22 01:45:24 +00:00
> Given variables $x_1,x_2,\ldots,x_N$ with constraints in the form $x_i-x_j\ge c$, compute a feasible solution.
2020-06-28 02:11:09 +00:00
<resources>
<resource source="MIT" title="Slides from Intro to Algorithms" url="https://www.cs.rit.edu/~spr/COURSES/ALG/MIT/lec18.pdf">Linear Programming Trick</resource>
</resources>
2020-06-22 01:45:24 +00:00
2020-06-28 02:11:09 +00:00
**Example:** Timeline (USACO Camp)
- equivalent to [Timeline (Gold)](http://www.usaco.org/index.php?page=viewproblem2&cpid=1017) except $N,C\le 5000$ and negative values of $x$ are possible.
2020-06-22 01:45:24 +00:00
2020-06-28 02:11:09 +00:00
### Problems
2020-06-28 03:56:39 +00:00
<problems-list problems={metadata.problems.linear} />