呃ABC问题
  • 板块灌水区
  • 楼主wuzhexu
  • 当前回复9
  • 已保存回复9
  • 发布时间2024/12/7 22:16
  • 上次更新2024/12/8 10:31:39
查看原帖
呃ABC问题
1174984
wuzhexu楼主2024/12/7 22:16

C题哪里有问题,自认为没有问题

#include<bits/stdc++.h>

using namespace std;

char c[1001][1001];

bool good[1001][1001];

#define int long long

signed main(){
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int h,w,d;
	
	cin>>h>>w>>d;
	
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>c[i][j];
			good[i][j]=1;
		} 
	}
	
	int ans=0;
	
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(c[i][j]=='H'){
				if(good[i][j]){
					ans++;
					good[i][j]=0;
				}
				for(int k=0;k<=d;k++){
					if(c[i+k][j]=='.' || c[i+k][j]=='H'){
						if(good[i+k][j]){
							ans++;
							good[i+k][j]=0;
						}
					}
				}
				for(int k=0;k<=d;k++){
					if(c[i-k][j]=='.' || c[i-k][j]=='H'){
						if(good[i-k][j]){
							ans++;
							good[i-k][j]=0;
						}
					}
				}
				for(int k=0;k<=d;k++){
					if(c[i][j+k]=='.' || c[i][j+k]=='H'){
						if(good[i][j+k]){
							ans++;
							good[i][j+k]=0;
						}
					}
				}
				for(int k=0;k<=d;k++){
					if(c[i][j-k]=='.' || c[i][j-k]=='H'){
						if(good[i][j-k]){
							ans++;
							good[i][j-k]=0;
						}
					}
				}
			}
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}
2024/12/7 22:16
加载中...