[F4] Escape problem (3 pts) [00SA]

An n \times n grid is an undirected graph consisting of n rows and n columns of vertices, as shown in the figure below. We denote the vertex in the ith row and the jth column by (i,j). All vertices in a grid have exactly four neighbors, except for the boundary vertices.

Given m \leq n^2 starting points (x_1, y_1), (x_2, y_2), \dots , (x_m, y_m) in the grid, the escape problem is to determine whether or not there are m vertex-disjoint paths (i.e. paths that do not share any vertices or edges) from the starting points to any m different points on the boundary. For example, the grid shown on the left has an escape, but the grid on the right does not.

Describe a polynomial-time algorithm to solve the escape problem, and analyze its running time.

Context

Max flow problems [00S6]

Related

[F3] Vertex capacities (2 pts) [00S9]