

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
縦 行、横 列からなるマス目があり、それぞれのマスは散らかっているか散らかっていないかのどちらかです。
今からあなたはこのマス目に つ布団を敷きます。
縦または横に隣接するマス目の内部の マスであって、いずれのマスも散らかっていない場所に布団を敷くことができます。
整数 と 個の長さ の文字列 が与えられます。 の 文字目が .
のとき、上から 行目、左から
列目のマスは散らかっていません。 の 文字目が #
のとき、上から 行目、左から
列目のマスは散らかっています。
布団を敷く場所の選び方は全部で何通りあるか求めてください。
制約
- は
.
と#
のみからなる長さ の文字列
入力
入力は以下の形式で標準入力から与えられる。
出力
布団を敷く場所の選び方の総数を出力せよ。
入力例 1Copy
2 3 ..# #..
出力例 1Copy
3
次の 通りの選び方があります。
- 上から 行目の左から 列目と 列目
- 上から 行目の左から 列目と 列目
- 左から 列目の上から 行目と 行目
入力例 2Copy
2 2 .# #.
出力例 2Copy
0
Score : points
Problem Statement
We have a grid with horizontal rows and 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 , , and strings of length each.
If the -th character of is .
, the square at the -th row from the top and the -th column from the left is tidy; if the -th character of is #
, the square at the -th row from the top and the -th column from the left is untidy.
Find the number of ways to choose the position for the mattress.
Constraints
- is a string of length consisting of
.
and#
.
Input
Input is given from Standard Input in the following format:
Output
Print the number of ways to choose the position for the mattress.
Sample Input 1Copy
2 3 ..# #..
Sample Output 1Copy
3
We have the following three choices:
- the -st and -nd squares from the left in the -st row from the top;
- the -nd and -rd squares from the left in the -nd row from the top; and
- the -st and -nd squares from the top in the -nd column the left.
Sample Input 2Copy
2 2 .# #.
Sample Output 2Copy
0