80?
查看原帖
80?
602624
___njr___楼主2022/12/18 13:37
#include<bits/stdc++.h>
using namespace std;

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
	return x*f;
}
int ans=0;
int n=read(),k=read();
bool maze[100010][100010];
int main()
{
	memset(maze,false,sizeof(maze));
	for(int i=0;i<k;i++) {
		int x=read(),y=read();
		if(maze[x][max(y-1,0)]) ans++;
		if(maze[x][min(y+1,n)]) ans++;
		if(maze[min(x+1,n)][y]) ans++;
		if(maze[max(x-1,0)][y]) ans++;
		maze[x][y]=true;
	}
	printf("%d\n",ans);
	return 0;
}



2022/12/18 13:37
加载中...