80分求助,#4和#5WA......但我没检查出有什么逻辑错误

P3654 First Step (ファーストステップ)

当K==1时,行列会把count重复计算两遍。 所以答案不正确。 改正也很简单,只需要当K==1时单独去考虑。 AC代码 ```cpp #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]=='.'){ if(K==1) count++; else { 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; } ```
by d3genera7e @ 2022-06-10 17:47:45


有个测试点是一个人的时候的,你这样会数重复的
by H2130819068 @ 2022-07-29 10:24:00


|