I spent way too long thinking about this as a greedy coverage problem, like just pick the row or column with the most zeros and repeat.
Model the problem as a minimum vertex cover in a bipartite graph where left nodes are rows and right nodes are columns, and each leaking cell (0) creates an edge between its row and column. By König's theorem, the minimum vertex cover size equals the maximum matching size, which can be computed efficiently using Hopcroft-Karp or DFS-based augmenting paths. The answer is the size of the maximum matching.
Pro tip: Explicitly connect the problem to König's theorem and mention that the minimum vertex cover gives the optimal set of planks (rows and columns). This shows deep theoretical knowledge and avoids a naive greedy approach.
Create a bipartite graph with one set of nodes for rows and another for columns. For each leaking cell (0) at (i, j), add an edge between row i and column j.
Covering all leaking cells with planks means selecting a set of rows and columns that cover all edges. This is exactly the minimum vertex cover problem in a bipartite graph.
State that in bipartite graphs, the size of the minimum vertex cover equals the size of the maximum matching. So the answer is the maximum matching size.
Use an efficient algorithm like Hopcroft-Karp (O(E√V)) or a simple DFS-based augmenting path algorithm (O(VE)). Since the graph is small (m+n nodes), either works.
The number of edges in the maximum matching is the minimum number of planks needed. Optionally, reconstruct the actual planks from the vertex cover.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.