跳到正文

个人记录

aaa

kjy30约 3 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年4月9日
篇幅
约 3 分钟

版本

  1. v1当前
C++
#include<bits/stdc++.h>
using namespace std;
int n,m,k,x,y,o,p,tmp;
int a[110][110];
int main()
{
	cin>>n>>m>>k;
	for(int i=1;i<=m;i++)
	{
		cin>>x>>y;
		a[x][y]=1;														//火把
		//x-2
		if(x-2>0) a[x-2][y]=1;
		//x-1
		if(x-1>0 and y-1>0) a[x-1][y-1]=1;
		if(x-1>0) a[x-1][y]=1;
		if(x-1>0 and y+1<=n) a[x-1][y+1]=1;
		//x
		if(y-2>0) a[x][y-2]=1;
		if(y-1>0) a[x][y-1]=1;
		if(y+1<=n) a[x][y+1]=1;
		if(y+2<=n) a[x][y+2]=1;
		//x+1
		if(x+1<=n and y-1>0) a[x+1][y-1]=1;
		if(x+1<=n ) a[x+1][y]=1;
		if(x+1<=n and y+1<=n) a[x+1][y+1]=1;
		//x+2
		if(x+2<=n) a[x+2][y]=1;
	}
	for(int i=1;i<=k;i++)
	{
		cin>>o>>p;
		a[o][p]=1;														//萤石
		 //o-2
		if(o-2>0 and p-2>0) a[o-2][p-2]=1;
		if(o-2>0 and p-1>0) a[o-2][p-1]=1;
		if(o-2>0) a[o-2][p]=1;
		if(o-2>0 and p+1<=n) a[o-2][p+1]=1;
		if(o-2>0 and p+2<=n) a[o-2][p+2]=1;
		//o-1
		if(o-1>0 and p-2>0) a[o-1][p-2]=1;
		if(o-1>0 and p-1>0) a[o-1][p-1]=1;
		if(o-1>0) a[o-1][p]=1;
		if(o-1>0 and p+1<=n) a[o-1][p+1]=1;
		if(o-1>0 and p+2<=n) a[o-1][p+2]=1;
		//o
		if(p-2>0) a[o][p-2]=1;
		if(p-1>0) a[o][p-1]=1;
		if(p+1<=n) a[o][p+1]=1;
		if(p+2<=n) a[o][p+2]=1;
		//o+1
		if(o+1<=n and p-2>0) a[o+1][p-2]=1;
		if(o+1<=n and p-1>0) a[o+1][p-1]=1;
		if(o+1<=n ) a[o+1][p]=1;
		if(o+1<=n and p+1<=n) a[o+1][p+1]=1;
		if(o+1<=n and p+2<=n) a[o+1][p+2]=1;
		//o+2
		if(o+2<=n and p-2>0) a[o+2][p-2]=1;
		if(o+2<=n and p-1>0) a[o+2][p-1]=1;
		if(o+2<=n) a[o+2][p]=1;
		if(o+2<=n and p+1<=n) a[o+2][p+1]=1;
		if(o+2<=n and p+2<=n) a[o+2][p+2]=1;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(a[i][j]==0) tmp++;
		}
	}
	cout<<tmp;
	return 0;
}
原文