消灭人类暴政,世界属于打表()

蒙自市凤凰小学又阝十尃亻二  •  1年前


//为什么我循环越界,而打表不越界???

include <bits/stdc++.h>

using namespace std; int a[306][300];

int main() {

int n, x, y, o, p, ans = 0, aa, bb;
cin >> n >> aa >> bb;
for (int i = 0; i < aa; i++) {
	cin >> x >> y;
	a[x][y] = 1;
	a[x - 2][y] = 1;
	a[x - 1][y] = 1;
	a[x + 1][y] = 1;
	a[x + 2][y] = 1;
	a[x][y + 1] = 1;
	a[x][y + 2] = 1;
	a[x][y - 1] = 1;
	a[x][y - 2] = 1;
	a[x - 1][y - 1] = 1;
	a[x + 1][y + 1] = 1;
	a[x - 1][y + 1] = 1;
	a[x + 1][y - 1] = 1;
}
for (int i = 0; i < bb; i++) {
	cin >> x >> y;
	a[x][y] = 1;
	a[x - 2][y] = 1;
	a[x - 1][y] = 1;
	a[x + 1][y] = 1;
	a[x + 2][y] = 1;
	a[x][y + 1] = 1;
	a[x][y + 2] = 1;
	a[x][y - 1] = 1;
	a[x][y - 2] = 1;
	a[x - 1][y - 1] = 1;
	a[x + 1][y + 1] = 1;
	a[x - 1][y + 1] = 1;
	a[x + 1][y - 1] = 1;
	a[x - 2][y - 2] = 1;
	a[x - 2][y - 1] = 1;
	a[x - 1][y - 2] = 1;
	a[x - 2][y + 2] = 1;
	a[x - 2][y + 1] = 1;
	a[x - 1][y + 2] = 1;
	a[x + 2][y - 2] = 1;
	a[x + 2][y - 1] = 1;
	a[x + 1][y - 2] = 1;
	a[x + 2][y + 2] = 1;
	a[x + 2][y + 1] = 1;
	a[x + 1][y + 2] = 1;
}
for (int i = 1; i <= n; i++) {
	for (int j = 1; j <= n; j++) {
		if (a[i][j] == 0) {
			ans++;
		}
	}
}
cout << ans;
return 0;

}


评论:

请先登录,才能进行评论