求助
查看原帖
求助
1125203
yurx楼主2023/11/11 15:58

4 0 分

谁 帮 忙 看 亿 下 代 码 , 哪 里 出 错 了 ?

#include<bits/stdc++.h>
using namespace std;

struct xy{
	int x, y;
};

int n, m, k, mn[105][105], ans;
xy fire[30], stone[7], text[5];

void put(int a, int b, int choose){
	if(choose){
		for(int i = -2; i <= 2; i++){
			if(a + i >= 0 && b + i >= 0) mn[a + i][b] = mn[a][b + i] = mn[a + text[i + 2].x][b + text[i + 2].y] = 1;
		}
	}
	else{
		for(int i = -2; i <= 2; i++){
			for(int i = -2; i <= 2; i++){
				if(a + i >= 0 && b + i >= 0) mn[a + i][b + i] = 1;
			}
		}
	}
}

int main(){
	
	text[0].x = text[1].x = text[0].y = text[2].y = 1;
	text[3].x = text[1].y = text[3].y = text[2].x = -1;
	
	cin >> n >> m >> k;
	for(int i = 0; i < m; i++) cin >> fire[i].x >> fire[i].y;
	for(int i = 0; i < k; i++) cin >> stone[i].x >> stone[i].y;
	
	for(int i = 0; i < m; i++) put(fire[i].x - 1, fire[i].y - 1, 1);
	for(int i = 0; i < k; i++) put(stone[i].x - 1, stone[i].y - 1, 0);
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(!mn[i][j]) ans++;
		}
	}
	
	cout << ans;
	
	return 0;
}
2023/11/11 15:58
加载中...