You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
# include <bits/stdc++.h>
using namespace std ;
const int N = 110 ;
char a [ N ] [ N ] ;
//以i,j为坐标的点, 向右找k个, 看看是不是都是空地; 向下找k个, 看看是不是都是空地
int check ( int i , int j , int k ) {
int cnt = 0 ;
//向右
bool found = true ;
for ( int x = j ; x < j + k ; x + + ) {
if ( a [ i ] [ x ] ! = ' . ' ) {
found = false ;
break ;
}
}
if ( found ) cnt + + ;
//向下
found = true ;
for ( int x = i ; x < i + k ; x + + ) {
if ( a [ x ] [ j ] ! = ' . ' ) {
found = false ;
break ;
}
}
if ( found ) cnt + + ;
return cnt ;
}
int r , c , K , ans ;
int main ( ) {
//篮球场是r行c列的矩阵
cin > > r > > c > > k ;
//读入地图
for ( int i = 1 ; i < = r ; i + + )
for ( int j = 1 ; j < = c ; j + + )
cin > > a [ i ] [ j ] ;
//遍历每一个位置,寻找连续空地
for ( int i = 1 ; i < = r ; i + + )
for ( int j = 1 ; j < = c ; j + + )
ans + = check ( i , j , k ) ;
//特判(美女一个人,向右看一个是自己,向下看一个又是自己,数据就错误翻倍了~)
if ( k = = 1 ) cout < < ans / 2 < < endl ;
else cout < < ans < < endl ;
return 0 ;
}