10pts求助
查看原帖
10pts求助
510360
HbugU楼主2022/1/20 06:39
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fr first
#define se second
#define FAST ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
int n,m,k,ans;
char a[105][105];
void right(int x,int y,int v){
    if(v==k){
        ans++;
        return;
    }
    if(a[x][y+1]=='.') right(x,y+1,v+1);
}
void under(int x,int y,int v){
    if(v==k){
        ans++;
        return;
    }
    if(a[x+1][y]=='.') right(x+1,y,v+1);
}
int main(){
    FAST;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>a[i][j];
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(a[i][j]=='.'){
                under(i,j,1);
                right(i,j,1);
            }
        }
    }
    cout<<ans;
    return 0;
}
2022/1/20 06:39
加载中...