洛谷P1789 【Mc生存】插火把

2024-06-04 11:23:20 浏览数 (1)

代码语言:javascript复制
#define  _CRT_SECURE_NO_WARNINGS 1

//用c  的头写c要不然会有一个RE
#include <iostream>
using namespace std;

int n, m, k, x, y, ans, a[101][101]; //数组不需要开那么大101足够

int main()
{
	scanf("%d %d %d", &n, &m, &k);

	//火把
	for (int i = 1; i <= m; i  )
	{
		scanf("%d %d", &x, &y);
		//防止数组越界
		x  = 2;
		y  = 2;
		for (int l = x - 1; l <= x   1; l  )
			for (int p = y - 1; p <= y   1; p  )
				a[l][p] = 1; //火把中间3*3的范围
		a[x - 2][y] = a[x   2][y] = a[x][y - 2] = a[x][y   2] = 1; //剩下的四个点单独标记
	}

	//萤石
	for (int i = 1; i <= k; i  )
	{
		scanf("%d %d", &x, &y);
		//防止数组越界
		x  = 2;
		y  = 2;
		for (int l = x - 2; l <= x   2; l  )
			for (int p = y - 2; p <= y   2; p  )
				a[l][p] = 1; //因为萤石的范围是5*5所以直接标记
	}

	//遍历
	for (int i = 1   2; i <= n   2; i  ) // 2后正常进行
		for (int j = 1   2; j <= n   2; j  )
			if (a[i][j] == 0) //未标记即为没有光生怪处
				ans  ;
	printf("%dn", ans);
	return 0;
}

0 人点赞