改了3遍还是80
查看原帖
改了3遍还是80
194790
祸榊__楼主2020/7/27 17:08
#include<bits/stdc++.h>
using namespace std;
#define li(i,j,k) for(int i=j ; i<=k ; i++)
#define si(i,j,k) for(int i=j ; i>=k ; i--)
int r,c,k;
char ground[201][201];
int ans=0;
int main(){
	scanf("%d%d%d",&r,&c,&k);
	li(i,1,r){
		scanf("%s",&ground[i]);
	}
	li(i,1,r){
		li(j,0,c-k){
			bool ok=true;
			li(kk,j,j+k-1){
				if(ground[i][kk]=='#'){
					ok=false;
					break;
				}
			}
			if(ok)ans++;
		}
	}
	li(i,1,r-k+1){
		li(j,0,c-1){
			bool ok=true;
			li(kk,i,i+k-1){
				if(ground[kk][j]=='#'){
					ok=false;
					break;
				}
			}
			if(ok)ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}
2020/7/27 17:08
加载中...