80分求助,#4和#5WA......但我没检查出有什么逻辑错误
查看原帖
80分求助,#4和#5WA......但我没检查出有什么逻辑错误
706459
Go_for_itligli666666楼主2022/5/15 12:14
#include<iostream>
using namespace std;
int main(){
    int R,C,K;
    cin>>R>>C>>K;
    char playground[R][C];
    for(int i=0;i<R;i++){
        for(int j=0;j<C;j++){
            cin>>playground[i][j];
        }
    }
    int count=0;
    for(int i=0;i<R;i++){
        for(int j=0;j<C;j++){
            if(playground[i][j]=='.'){
                //分别枚举行列
                int m=0;
                while(m+j<C&&playground[i][m+j]=='.'){
                    m++;
                }
                if(m>=K){
                    count++;
                }
                int n=0;
                while(n+i<R&&playground[n+i][j]=='.'){
                    n++;
                }
                if(n>=K){
                    count++;
                }
            }
        }
    }
    cout<<count<<endl;
}
2022/5/15 12:14
加载中...