为什么只有40分,脑袋瓜子嗡嗡的
查看原帖
为什么只有40分,脑袋瓜子嗡嗡的
349592
轮回·天照楼主2021/4/3 20:54
#include <bits/stdc++.h>
using namespace std;
struct node{
	int x;
	int y;
};
int n,m,k,maps[1000][1000];
node t[1000],c[1000];
void torch(node nod){
	int tx = nod.x;
	int ty = nod.y;
	maps[tx][ty]++;
	if(tx > 1) maps[tx-1][ty]++;
	if(tx > 2) maps[tx-2][ty]++;
	if(tx < n) maps[tx+1][ty]++;
	if(tx < n - 1) maps[tx+2][ty]++;
	if(ty > 1) maps[tx][ty-1]++;
	if(ty > 2) maps[tx][ty-2]++;
	if(ty < n) maps[tx][ty+1]++;
	if(ty < n - 1) maps[tx][ty+2]++;
	if(tx > 1 && ty > 1) maps[tx-1][ty-1]++;
	if(tx > 1 && ty < n) maps[tx-1][ty+1]++;
	if(tx < n && ty > 1) maps[tx+1][ty-1]++;
	if(tx < n && ty < n) maps[tx+1][ty+1]++;
}
void cann(node nod){
	int tx = nod.x;
	int ty = nod.y;
	if(ty > 2){
		if(tx > 2) maps[tx-2][ty-2]++;
		if(tx > 1) maps[tx-1][ty-2]++;
		maps[tx][ty-2]++;
		if(tx < n) maps[tx+1][ty-2]++;
		if(tx < n - 1) maps[tx+2][ty-2]++;
	}
	if(ty > 1){
		if(tx > 2) maps[tx-2][ty-1]++;
		if(tx > 1) maps[tx-1][ty-1]++;
		maps[tx][ty-1]++;
		if(tx < n) maps[tx+1][ty-1]++;
		if(tx < n - 1) maps[tx+2][ty-1]++;
	}
	if(ty < m){
		if(tx > 2) maps[tx-2][ty+1]++;
		if(tx > 1) maps[tx-1][ty+1]++;
		maps[tx][ty-2]++;
		if(tx < n) maps[tx+1][ty+1]++;
		if(tx < n - 1) maps[tx+2][ty+1]++;
	}
	if(ty < m - 1){
		if(tx > 2) maps[tx-2][ty+2]++;
		if(tx > 1) maps[tx-1][ty+2]++;
		maps[tx][ty+2]++;
		if(tx < n) maps[tx+1][ty+2]++;
		if(tx < n - 1) maps[tx+2][ty+2]++;
	}
}
int main(){
	cin >> n >> m >> k;
	for(int i = 1;i <= m;i++)
		cin >> t[i].x >> t[i].y;
	if(k)
		for(int i = 1;i <= k;i++)
			cin >> c[i].x >> c[i].y;
	for(int i = 1;i <= m;i++)
		torch(t[i]);
	if(k)
		for(int i = 1;i <= k;i++)
			cann(t[i]);
	int ans = 0;
	for(int i = 1;i <= n;i++)
		for(int j = 1;j <= n;j++)
			if(!maps[i][j])
				ans++;
	cout << ans;
	return 0;
}
2021/4/3 20:54
加载中...