Solve a game of flood
CJam (77 bytes)

{Ma+a{():B;:A:|{A((:C;0\+a\+_e_,2*{[0C]f/[0_]f*z}*{0Der}%BD+a+a+}fDAe_(-}g;B}


Online demo. This is an anonymous block (function) which takes the input as a 2D array and provides the output as a 1D array.