P23709 [AtCoder] [ABC018C] Diamond Count
普及+
题目描述

Problem Description

There is a rectangular area with $ R $ rows and $ C $ columns. Let the square at the $i\ (1\ ≦\ i\ ≦\ R)$th row and $j\ (1\ ≦\ j\ ≦\ C)$th column be called square ($ i $, $ j $). Some of these squares are painted black, and the others are painted white.

An integer $ K $ is also given.

We consider painting new squares green under the following conditions. This operation is performed only once.

  • For some pair of integers $x\ (K\ ≦\ x\ ≦\ R\ -\ K\ +\ 1)$ and $y\ (K\ ≦\ y\ ≦\ C\ -\ K\ +\ 1)$, all squares ($ i $, $ j $) satisfying $ |i-x| + |j-y| ≦ K - 1 $ are originally white and are painted green in this operation. Furthermore, all squares satisfying $ |i-x| + |j-y| ≧ K $ are not painted green.

How many such ways of painting are there? Here, a way of painting refers to the combination of which squares are painted which colors, and the order of painting is not considered.

Input Format

The input is given from the standard input in the following format.

$ R $ $ C $ $ K $ $ s_1 $ $ s_2 $ : $ s_R $

  • The first line contains three integers $R\ (3\ ≦\ R\ ≦\ 500)$, $C\ (3\ ≦\ C\ ≦\ 500)$, and $K\ (2\ ≦\ K\ ≦\ 500)$ separated by spaces. This indicates that the rectangular area has $ R $ rows and $ C $ columns. $ K $ is the integer mentioned in the text.
  • The next $ R $ lines provide information about the squares. The $i\ (1\ ≦\ i\ ≦\ R)$th line contains a string $ s_i $ of length $ C $. The string $ s_i $ consists only of the characters o and x. If the $j\ (1\ ≦\ j\ ≦\ C)$th character from the left in $ s_i $ is o, the square ($ i $, $ j $) is a white square; if it is x, the square ($ i $, $ j $) is a black square.

Output Format

Output the total number of ways to paint the squares green in one line. End the output with a newline.

Sample Input and Output

Sample Input #1

4 5 2
xoooo
oooox
ooooo
oxxoo

Sample Output #1

3

Sample Input #2

4 5 2
ooooo
oxoox
oooox
oxxoo

Sample Output #2

0

Sample Input #3

8 6 3
oooooo
oooooo
oooooo
oooooo
oxoooo
oooooo
oooooo
oooooo

Sample Output #3

4

Notes/Hints

Partial Points

This problem has partial points.

  • If you solve the dataset $ 1 $ where $R\ ≦\ 50$ and $C\ ≦\ 50$, you will be awarded $ 30 $ points.

Sample Explanation 1

The following three ways are possible (o represents a white square, x represents a black square, and * represents a green square).

x*ooo
**oox
oooox
xooox

xo*ooo
**oox
oooox
xooox

xoooo
oo*xoo
**oxx
o*o
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
4 5 2 xoooo oooox ooooo oxxoo
样例输出
3