B - Futon Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 200200

問題文

HH 行、横 WW 列からなるマス目があり、それぞれのマスは散らかっているか散らかっていないかのどちらかです。

今からあなたはこのマス目に 11 つ布団を敷きます。

縦または横に隣接するマス目の内部の 22 マスであって、いずれのマスも散らかっていない場所に布団を敷くことができます。

整数 H,WH, WHH 個の長さ WW の文字列 SiS_i が与えられます。 SiS_ijj 文字目が . のとき、上から ii 行目、左から jj 列目のマスは散らかっていません。SiS_ijj 文字目が # のとき、上から ii 行目、左から jj 列目のマスは散らかっています。

布団を敷く場所の選び方は全部で何通りあるか求めてください。

制約

  • 2H1002 \leq H \leq 100
  • 2W1002 \leq W \leq 100
  • SiS_i.# のみからなる長さ WW の文字列

入力

入力は以下の形式で標準入力から与えられる。

HH WW
S1S_1
::
SHS_H

出力

布団を敷く場所の選び方の総数を出力せよ。


入力例 1Copy

Copy
2 3
..#
#..

出力例 1Copy

Copy
3

次の 33 通りの選び方があります。

  • 上から 11 行目の左から 11 列目と 22 列目
  • 上から 22 行目の左から 22 列目と 33 列目
  • 左から 22 列目の上から 11 行目と 22 行目

入力例 2Copy

Copy
2 2
.#
#.

出力例 2Copy

Copy
0

Score : 200200 points

Problem Statement

We have a grid with HH horizontal rows and WW vertical columns of squares, where each square is tidy or untidy.

You will now place a mattress on this grid.

The mattress can be placed on two horizontally or vertically adjacent tidy squares in the grid.

Given are integers HH, WW, and HH strings SiS_i of length WW each. If the jj-th character of SiS_i is ., the square at the ii-th row from the top and the jj-th column from the left is tidy; if the jj-th character of SiS_i is #, the square at the ii-th row from the top and the jj-th column from the left is untidy.

Find the number of ways to choose the position for the mattress.

Constraints

  • 2H1002 \leq H \leq 100
  • 2W1002 \leq W \leq 100
  • SiS_i is a string of length WW consisting of . and #.

Input

Input is given from Standard Input in the following format:

HH WW
S1S_1
::
SHS_H

Output

Print the number of ways to choose the position for the mattress.


Sample Input 1Copy

Copy
2 3
..#
#..

Sample Output 1Copy

Copy
3

We have the following three choices:

  • the 11-st and 22-nd squares from the left in the 11-st row from the top;
  • the 22-nd and 33-rd squares from the left in the 22-nd row from the top; and
  • the 11-st and 22-nd squares from the top in the 22-nd column the left.

Sample Input 2Copy

Copy
2 2
.#
#.

Sample Output 2Copy

Copy
0


2025-04-14 (Mon)
18:28:44 +00:00