AdvancedRating 1600
Shortest Bridge
The grid has exactly two islands of # (cells connected up, down, left, right). Print the fewest water cells you must turn into land to connect them.
Input
r and c, then r rows.
Output
One integer.
Sample 1
Input
2 2 #. .#
Output
1
Sample 2
Input
3 3 #.. ... ..#
Output
3
Output appears here