跳到正文

个人记录

666

hemu0104约 1 分钟
原文
文章信息与版本

文章信息

发布
2025年10月17日
收录
2025年12月12日
更新
2026年11月14日
篇幅
约 1 分钟

版本

  1. v1当前
C++
#include<bits/stdc++.h>
using namespace std;
int xx[14]={0,2,1,1, 1,0,0,0, 0, 0,-1,-1,-1,-2};
int yy[14]={0,0,1,0,-1,2,1,0,-1,-2, 1, 0,-1, 1};
int n,m,k,ans;
bool a[105][105];
bool vis[105][105];
int main(){
	cin>>n>>m>>k;
	for(int i=1;i<=k;i++){
		int x,y;
		cin>>x>>y;
		a[x][y]=1;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(a[i][j]==0){
				for(int z=1;z<=13;z++){
					if(i+xx[z]>=1&&i+xx[z]<=n&&j+yy[z]>=1&&j+yy[z]<=m){
						if(vis[i+xx[z]][j+yy[z]]==0&&a[i+xx[z]][j+yy[z]]==1){
							vis[i+xx[z]][j+yy[z]]=1;
							ans++;
						}
					}
				}
			}
		}
	}
	cout<<ans;
	return 0;
}
/*
0 0 1 0 0
0 1 1 1 0
1 1 1 1 1
0 1 1 1 0
0 0 1 0 0
*/
原文