CSES - Police Chase

Author: Dong Liu


Time Complexity: O(N3)\mathcal O(N^3)

First, we run a max flow algorithm on the graph. Then, we run another BFS from node 11. If node aa is reachable but node bb is not and there was an edge aba\rightarrow b, then we know that edge must be removed.

C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
#define f first
#define s second
#define pb push_back
#define all(x) begin(x), end(x)

Join the USACO Forum!

Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!