#include <bits/stdc++.h>
#define int long long
#define N 60
using namespace std;

int n,m;
char a[N][N];
int ans;

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i=3;i<=n+2;++i){
		for (int j=3;j<=m+2;++j){
			cin >> a[i][j];
		}
	}
	for (int i=3;i<=n+2;++i){
		for (int j=3;j<=m+2;++j){
			if (a[i][j] == '#') continue;

			// 竖
			if(a[i+1][j] == '#' && a[i-1][j] == '#') ans++;
			else if(a[i+1][j] == '#' && a[i+2][j] == '#') ans++;
			else if(a[i-1][j] == '#' && a[i-2][j] == '#') ans++;
			// 横
			else if(a[i][j+1] == '#' && a[i][j-1] == '#') ans++;
			else if(a[i][j+1] == '#' && a[i][j+2] == '#') ans++;
			else if(a[i][j-1] == '#' && a[i][j-2] == '#') ans++;
			//斜
			else if(a[i+1][j+1] == '#' && a[i-1][j-1] == '#') ans++;
			else if(a[i+1][j+1] == '#' && a[i+2][j+2] == '#') ans++;
			else if(a[i-1][j-1] == '#' && a[i-2][j-2] == '#') ans++;
			
			else if(a[i-1][j+1] == '#' && a[i+1][j-1] == '#') ans++;
			else if(a[i-1][j+1] == '#' && a[i-2][j+2] == '#') ans++;
			else if(a[i+2][j-2] == '#' && a[i+1][j-1] == '#') ans++;
		}
	}
	cout << ans;


    
    
    return 0;
}

0 条评论

目前还没有评论...

信息

ID
152
时间
ms
内存
MiB
难度
1
标签
递交数
63
已通过
27
上传者