六十分求助
查看原帖
六十分求助
1139102
wanMCdeAlex楼主2025/1/18 18:59
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
	int m,n,k2;
	cin>>n>>m>>k2;
	bool list[n][n];
	int iuse1,iuse2;
	for (int i = 1;i <= n;i ++){
		for (int k = 1;k <= n;k ++){
			list[i][k] = false;
		}
	}
	
	
	for (int i = 1;i <= m;i ++){
		cin>>iuse1>>iuse2;
		list[iuse1][iuse2] = true;
		list[iuse1 - 2][iuse2] = true;
		list[iuse1 - 1][iuse2] = true;
		list[iuse1 + 1][iuse2] = true;
		list[iuse1 + 2][iuse2] = true;
		list[iuse1][iuse2 - 2] = true;
		list[iuse1][iuse2 - 1] = true;
		list[iuse1][iuse2 + 1] = true;
		list[iuse1][iuse2 + 2] = true;
		list[iuse1 - 1][iuse2 - 1] = true;
		list[iuse1 + 1][iuse2 - 1] = true;
		list[iuse1 - 1][iuse2 + 1] = true;
		list[iuse1 + 1][iuse2 + 1] = true;
//		cout<<1<<endl;
	}
	
	
	for (int i = 1;i <= k2;i ++){
		cin>>iuse1>>iuse2;
		for (int k = iuse1 - 2;k <= iuse1 + 2;k ++){
			for (int e = iuse2 - 2;e <= iuse2 + 2;e ++){
				list[k][e] = true;
//				cout<<2<<endl;
			}
		}
	}
	
	int sum = 0;
	for (int i = 1;i <= n;i ++){
		for (int k = 1;k <= n;k ++){
			if (list[i][k] == false){
				sum ++;
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}

第一个和第四个不过

2025/1/18 18:59
加载中...