60分,2和3 RE,求解
查看原帖
60分,2和3 RE,求解
971647
usercppzyw楼主2024/1/13 18:33
#include<bits/stdc++.h>
using namespace std;
#define dark 0//黑暗
#define light 1//光
#define torch 2 //火把
#define glowstone 3//萤石
//以下0,1,2,3分别用dark,light,torch,glowstone代替
int a[128][128];
int main()
{
	int m,n,k,x,y,cnt=0;
	cin>>n>>m>>k;
	for(int i=1;i<=m;i++)
	{
		cin>>x>>y;
		a[x][y]=torch;
		a[x][y+1]=light;
		a[x][y+2]=light;
		a[x][y-1]=light;
		a[x][y-2]=light;
		a[x-1][y]=light;
		a[x-2][y]=light;
		a[x+1][y]=light;
		a[x+2][y]=light;
		a[x+1][y+1]=light;
		a[x-1][y-1]=light;
		a[x-1][y+1]=light;
		a[x+1][y-1]=light;
	}
	for(int i=1;i<=k;i++)
	{
		cin>>x>>y;
		a[x][y]=glowstone;
		for(int j=x-2;j<=x+2;j++)
		{
			for(int p=y-2;p<=y+2;p++)
			{
				a[j][p]=light;
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(a[i][j]==dark)
			{
				cnt++;
			}
		}
	}
	cout<<cnt;
	return 0;
}
2024/1/13 18:33
加载中...