Minimum Cut
Author: Benjamin Qi
Prerequisites
?
Focus Problem – read through this problem before continuing!
Resources
The resources below include many clever applications of min cut, including the Closure Problem.
Resources | |||
---|---|---|---|
CPC | Slides from "Algorithm Design." Min-Cut Max-Flow Theorem, applications of flow / min cut. | ||
CPH | Brief descriptions of flow / min cut applications. |
Solution - Coin Grid
This problem asks us for the minimum node cover of a bipartite graph. Construct a flow graph with vertices labeled , source , sink , and the following edges:
- Edges from with capacity for each . Cutting the -th such edge corresponds to choosing the -th row.
- Edges from with capacity for each . Cutting the -th such edge corresponds to choosing the -th column.
- If there exists a coin in add an edge from with capacity .
First we find a max flow, which tells us the number of edges with capacity 1 we need to cut. To find the min cut itself, BFS from the source once more time. Edges connecting vertices that are reachable from the source (lev[a] != -1
) to vertices that aren't (lev[b] == -1
) are part of the minimum cut. In this case, each of these edges must be of the form or for . Each cut edge corresponds to a row or column we remove coins from.
Note that edges of the form can't be cut because they have capacity .
struct Dinic { // flow templateusing F = ll; // flow typestruct Edge { int to; F flo, cap; };int N; V<Edge> eds; V<vi> adj;void init(int _N) { N = _N; adj.rsz(N), cur.rsz(N); }/// void reset() { trav(e,eds) e.flo = 0; }void ae(int u, int v, F cap, F rcap = 0) { assert(min(cap,rcap) >= 0);adj[u].pb(sz(eds)); eds.pb({v,0,cap});adj[v].pb(sz(eds)); eds.pb({u,0,rcap});}
Path Covers
Resources | |||
---|---|---|---|
CPH | |||
Wikpedia |
Status | Source | Problem Name | Difficulty | Tags | Solution |
---|---|---|---|---|---|
Kattis | Hard | View Solution |
https://www.facebook.com/codingcompetitions/hacker-cup/2015/round-3/problems/C
Problems
Status | Source | Problem Name | Difficulty | Tags | Solution |
---|---|---|---|---|---|
CSES | Easy | View Solution | |||
Old Gold | Easy | Show TagsMax Flow | External Sol | ||
CSA | Normal | Check CSA | |||
CF | Normal | Check CF | |||
CF | Normal | Check CF | |||
CF | Hard | Check CF | |||
AC | Hard | Check AC |