Editorial for DMOPC '20 Contest 7 P5 - Mayors and Tolls
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
This problem can be solved with min cut / max flow. There are two main approaches:
Solution 1
Our construction has
By adding infinite-capacity edges from the roads to the incident cities, the minimum cut problem now has the constraints that for every profit we profit from, we must pay both incident cities.
So, the answer can be determined after
finding the min cut / max flow for this network with
Solution 2
Let
So, the answer can be written as
Or equivalently, as
where
This is very close to a minimum cut problem.
To turn it into one,
we add a source and sink
and add an arc to every node
to either the source or sink
depending on whether
The resulting flow construction has
Comments