Files
python/TangDou/LuoGuBook/P1789.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

53 lines
1.8 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int a[N][N];
int main() {
int n, m, k; //n*n的方阵m 个火把和 k 个萤石
cin >> n >> m >> k;
//火把
for (int i = 1; i <= m; i++) {
//火把位置
int x, y;
cin >> x >> y;
//火把的办量是有限的只能向上两行向下两行shit~
if (x - 1 >= 1)a[x - 1][y] = 1;
if (x - 2 >= 1)a[x - 2][y] = 1;
if (x + 1 <= n)a[x + 1][y] = 1;
if (x + 2 <= n)a[x + 2][y] = 1;
//火把的办量是有限的只能向左两列向右两列shit~
if (y - 1 >= 1)a[x][y - 1] = 1;
if (y - 2 >= 1)a[x][y - 2] = 1;
if (y + 1 <= n)a[x][y + 1] = 1;
if (y + 2 <= n)a[x][y + 2] = 1;
//斜着的还有4个方向距离只能为1
if (x - 1 >= 1 && y - 1 >= 1)a[x - 1][y - 1] = 1;//左上
if (x - 1 >= 1 && y + 1 <= n)a[x - 1][y + 1] = 1;//左下
if (x + 1 <= n && y - 1 >= 1)a[x + 1][y - 1] = 1;//右上
if (x + 1 <= n && y + 1 <= n)a[x + 1][y + 1] = 1;//右下
//火把的位置
a[x][y] = 1;
}
//萤石
for (int i = 1; i <= k; i++) {
int x, y;
cin >> x >> y;
//萤石这个玩意比火把厉害多了啊!
for (int j = x - 2; j <= x + 2; j++)
for (k = y - 2; k <= y + 2; k++)
if (j >= 1 && k >= 1 && j <= n && k <= n)
a[j][k] = 1;
//因为这两层循环把a[x][y]已经带上了就没有必要再次a[x][y]=1了
}
//统计没有出现过的位置,就是怪物可能出现的位置
int cnt = 0;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; ++j)
if (!a[i][j])cnt++;
//输出大吉
printf("%d", cnt);
return 0;
}