好——简——单。
查看原帖
好——简——单。
1465369
wangshengxi218楼主2024/11/21 19:50
#include <iostream>
using namespace std;
int main() {
	int n, m, k;
	int xi, yi;
	int oi, pi;
	cin >> n >> m >> k;
	bool arr[n + 6][n + 6];
	for (int i = 0; i < n + 6; i++) {
		for (int j = 0; j < n + 6; j++) {
			arr[i][j] = 0;
		}
	}
	for (int i = 0; i < m; i++) {
		cin >> xi >> yi;
		arr[xi + 1][yi + 1] = 1;

		arr[xi + 1][yi - 1] = 1;
		arr[xi + 1][yi] = 1;
		arr[xi + 1][yi + 2] = 1;
		arr[xi + 1][yi + 3] = 1;

		arr[xi - 1][yi + 1] = 1;
		arr[xi][yi + 1] = 1;
		arr[xi + 2][yi + 1] = 1;
		arr[xi + 3][yi + 1] = 1;

		arr[xi][yi] = 1;
		arr[xi][yi + 2] = 1;
		arr[xi + 2][yi] = 1;
		arr[xi + 2][yi + 2] = 1;
	}

	for (int i = 0; i < k; i++) {
		cin >> oi >> pi;
		for (int j = oi - 1; j <= oi + 3; j++) {
			for (int l = pi - 1; l <= pi + 3; l++) {
				arr[j][l] = 1;
			}
		}
	}
	int sum = 0;
	for (int i = 2; i < n + 2; i++) {
		for (int j = 2; j < n + 2; j++) {
			//cout << arr[i][j];
			if (!arr[i][j]) sum++;
		}
		//cout <<endl;
	}
	cout << sum;
	return 0;
}
2024/11/21 19:50
加载中...