[Community puzzle] Unflood The World

I used unionfind (disjoint set) at first with sorting / rowmajor indexing and it failed only maze 2. Then switched to BFS and it worked