atcoder#ABC211E. [ABC211E] Red Polyomino
[ABC211E] Red Polyomino
Score : points
Problem Statement
You are given a grid with rows and columns, where the square at the -th row from the top and -th column from the left is painted black if is #
and white if is .
.
You will choose of the white squares and paint them red. How many such ways to paint the grid satisfy the following condition?
- The squares painted red will be connected. That is, you will be able to get from any red square to any red square by repeatedly moving horizontally or vertically while only visiting red squares.
Constraints
- Each is
#
or.
. - and are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
3
5
#.#
...
..#
5
We have five ways to satisfy the condition as shown below, where @
stands for a red square.
#.# #@# #@# #@# #@#
@@@ .@@ @@. @@@ @@@
@@# @@# @@# .@# @.#
Note that the way shown below does not satisfy the connectivity requirement since we do not consider diagonal adjacency.
#@#
@.@
@@#
2
2
#.
.#
0
There is no way to satisfy the condition.
8
8
........
........
........
........
........
........
........
........
64678