80分求助#2WA
查看原帖
80分求助#2WA
759274
Stevehim楼主2022/8/18 11:14
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
int n, m, k;

int main() {
	cin >> n >> m >> k;
	int a[n + 1][n + 1];
	for (int i = 1 ; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			a[i][j] = 0;
		}
	}
	int huo[m + 1];
	int ying[k + 1];
	//下面是火把
	int x, y;
	for (int i = 1; i <= m; i++) {
		cin >> x >> y;
//		cout << "火把" << endl;
		a[x][y] = 1;
		a[x - 1][y - 1] = 1;
		a[x + 1][y - 1] = 1;
		a[x + 1][y + 1] = 1;
		a[x - 1][y + 1] = 1;
		for (int j = x - 2; j <= x + 2; j++) {
//			cout << j << "  " << y << endl;
			a[j][y] = 1;
		}
		for (int j = y - 2; j <= y + 2; j++) {
//			cout << x << "  " << j << endl;
			a[x][j] = 1;
		}
	}
	//下面是萤石
	for (int i = 1; i <= k; i++) {
//		cout << "萤石" << endl;
		cin >> x >> y;
		a[x][y] = 1;
		for (int j = x - 2; j <= x + 2; j++) {
			for (int aa = y - 2; aa <= y + 2; aa++) {
				a[j][aa] = 1;
			}
		}
	}
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (a[i][j] == 0) {
				sum++;
			}
		}
	}
	cout << sum;
	return 0;
}

不知道关于火把的判定错在了哪里。。

2022/8/18 11:14
加载中...