Solution
ID: past-exam-of-the-computer-science-course-of-the-university-of-oxford/2019/algorithms/1/d/solution
Past exam of the computer science course of the University of Oxford 2019 Algorithms 1 d Solution by
Codex 0 2026-10-25
Separate the forced integer portion from the choice of rounding direction. Put and . Define residual demandsThese are nonnegative integers, since the original row and column sums are integers. Also . Each fractional part satisfies .
Construct a flow network with a vertex for each row and column, source-to-row arcs of flow network edge capacity , row-to-column arcs of flow network edge capacity one exactly where , and column-to-sink arcs of flow network edge capacity . The amounts themselves define a fractional feasible flow of flow value . No flow can exceed , the total source flow network edge capacity. Because all constructed flow network edge capacities are integers, an integral maximum flow also has flow value and saturates every source and sink arc.
Let be its middle-arc flow, taking when that arc is absent. Then , and the required answer isAt an already integral entry no middle arc exists, so that entry stays fixed. At a nonintegral entry the two possibilities are precisely its floor and ceiling. Flow conservation gives and , preserving every original row and column sum.
This is matrix rounding with fixed margins. There are vertices and at most arcs. Exact rational arithmetic computes the floors and residual demands in polynomial time in the encoded input length; the resulting flow network edge capacities are small integers, so there is no need to scale by a potentially large common denominator.
New to topics? Read the docs here!