#abc211e. E - Red Polyomino
E - Red Polyomino
Score : points
问题陈述
你得到一个 行和 列的网格,其中从上到下第 行、从左到右第 列的方格,如果 为 #
,则涂成黑色;如果 为.
,则涂成白色。
你需要从白色方格中选出 个,并将它们涂成红色。有多少种涂色方式满足以下条件?
- 涂成红色的方格彼此相连。也就是说,你可以通过仅访问红色方格并不断水平或垂直移动,从任意一个红色方格到达其他任意一个红色方格。
以上为通义千问 qwen-max 翻译,仅供参考。
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.
Sample Input 1
3
5
#.#
...
..#
Sample Output 1
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.
#@#
@.@
@@#
Sample Input 2
2
2
#.
.#
Sample Output 2
0
There is no way to satisfy the condition.
Sample Input 3
8
8
........
........
........
........
........
........
........
........
Sample Output 3
64678
update @ 2024/3/10 09:26:09