2433: 【普及-】【P3654】First Step

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:1 解决:1

题目描述

我们浦之星女子学院的篮球场是一个 lns="http://www.w3.org/1998/Math/MathML"> 行 lns="http://www.w3.org/1998/Math/MathML"> 列的矩阵,其中堆满了各种学校的杂物 (用 # 表示),空地 (用 . 表示) 好像并不多的样子呢……

我们 Aqours 现在已经一共有 lns="http://www.w3.org/1998/Math/MathML"> 个队员了,要歌唱舞蹈起来的话,我们得排成一条 lns="http://www.w3.org/1998/Math/MathML">1× 的直线,一个接一个地站在篮球场的空地上呢 (横竖均可)。

我们想知道一共有多少种可行的站位方式呢。

Aqours 的真正的粉丝的你,能帮我们算算吗?

输入

第一行三个整数 lns="http://www.w3.org/1998/Math/MathML">,,

接下来的 lns="http://www.w3.org/1998/Math/MathML"> 行 lns="http://www.w3.org/1998/Math/MathML"> 列,表示浦之星女子学院篮球场。

输出

总共的站位方式数量。

样例输入 复制

5 5 2
.###.
##.#.
..#..
#..#.
#.###

样例输出 复制

8

提示


lns="http://www.w3.org/1998/Math/MathML"> lns="http://www.w3.org/1998/Math/MathML"> lns="http://www.w3.org/1998/Math/MathML"> 备注
lns="http://www.w3.org/1998/Math/MathML">12 lns="http://www.w3.org/1998/Math/MathML">10 lns="http://www.w3.org/1998/Math/MathML">10 lns="http://www.w3.org/1998/Math/MathML">min(,)
lns="http://www.w3.org/1998/Math/MathML">34 lns="http://www.w3.org/1998/Math/MathML">100 lns="http://www.w3.org/1998/Math/MathML">100 lns="http://www.w3.org/1998/Math/MathML">1
lns="http://www.w3.org/1998/Math/MathML">56 lns="http://www.w3.org/1998/Math/MathML">100 lns="http://www.w3.org/1998/Math/MathML">100 lns="http://www.w3.org/1998/Math/MathML">min(,) 没有障碍
lns="http://www.w3.org/1998/Math/MathML">710 lns="http://www.w3.org/1998/Math/MathML">100 lns="http://www.w3.org/1998/Math/MathML">100 lns="http://www.w3.org/1998/Math/MathML">min(,)

对于所有数据,lns="http://www.w3.org/1998/Math/MathML">1,100lns="http://www.w3.org/1998/Math/MathML">1min(,)

#include<bits/stdc++.h>
using namespace std;
int R,C,K,ans,cnt;
char a[110][110];
int main(){
    cin>>R>>C>>K;
    for (int i=1;i<=R;i++) {
    	for (int j=1;j<=C;j++) {
		    cin>>a[i][j];
		    if (a[i][j]=='.') cnt++;
		}		
		getchar();
    }
	if (K==1) {
		cout<<cnt;
		return 0;
	}   
    for (int i=1;i<=R;i++) {
    	cnt=0;
    	for (int j=1;j<=C+1;j++) {
    		if (a[i][j]=='.') {
    			cnt+=1;
			}else {
				if (cnt>=K) ans+=cnt-K+1;
				cnt=0;
			}
		}
	}  
    for (int i=1;i<=C;i++) {
    	cnt=0;
    	for (int j=1;j<=R+1;j++) {
    		if (a[j][i]=='.') {
    			cnt+=1;
			}else {
				if (cnt>=K) ans+=cnt-K+1;
				cnt=0;
			}
		}
	}
    cout<<ans;
	return 0;
}