An nxn 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, which are the points (i, j) for which i=1, j=1, i=n, or j=n.
The escape puzzle begins with m n^2 starting points (x, y), (x, y), ..., (m, y), shown as dots in the figure to the right. Each dot can escape by taking a path from the point to the boundary that does not cross any occupied points, but no two dots can share the same edge on their escape. We want to determine whether all m dots can escape. For example, the grid in the left figure has an escape (shown in grey), but the grid in the right figure does not.
Describe an efficient algorithm that utilizes network flow to solve the escape problem. Analyze its running time. (Hint: You will need to apply more than one problem transformation to get a viable flow graph for the problem. One of the above problems is relevant, and the Kardashians might help you too - but they don't know the answer.)