各位看看哪儿有问题啊,跪求了!!
查看原帖
各位看看哪儿有问题啊,跪求了!!
1015241
lxy040208楼主2023/6/1 15:21
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n, m, k, x, y, p, o, x1, y1;
	cin >> n >> m >> k;
	int sun[100][100] = { 0 };
	int dir1[3] = { 0, 1, -1 };
	int dir2[3] = { 1, -1, 0 };
	for (int l = 0; l<m; l++)
	{
		cin >> x >> y;
		for (int i = 0; i<3; i++)
		{
			for (int j = 0; j<3; j++)
			{
				if ((x + dir1[i] < n + 1) && (y + dir2[j] < n + 1)&&((x-dir1[i])>0)&&(y-dir2[j]>0))
				{
					sun[x + dir1[i]][y + dir2[j]] = 1;
					sun[x + 2][y] = 1; sun[x - 2][y] = 1; sun[x][2] = 1; sun[x][-2] = 1;
				}
			}
		}
	}
	for (int i = 0; i < k; i++)
	{
		cin >> x1 >> y1;
		for (int w = -2; w <= 2; w++)
		{
			for (int r = -2; r <= 2; r++)
			{
				if ((x + dir1[w] < n + 1) && (y + dir2[r] < n + 1) && ((x - dir1[w])>0) && (y - dir2[r]>0))
				{
					if (sun[x1][y1] == 0)
						sun[x1 + w][y1 + r] == 1;
				}
			}
		}
	}
	int abc = 0;
	for (int o = 0; o<n; o++)
	{
		for (int p = 0; p<n; p++)
		{
			if (sun[o][p] != 1)
				abc++;
		}
	}
	cout << abc << endl;
	return 0;
}
2023/6/1 15:21
加载中...