话不多说 大家自己去理解吧我直接放代码:
#include <bits/stdc++.h>
using namespace std;
int a[105][105];
int main(){
int n, m, k, ans = 0;
cin >> n >> m >> k;
while(m--){
int x, y;
cin >> x >> y;
for(int i = x - 2; i <= x + 2; ++i)
if(i > 0)
a[i][y] = 1;
for(int i = y - 2; i <= y + 2; ++i)
if(i > 0)
a[x][i] = 1;
a[x - 1][y - 1] = a[x - 1][y + 1] = a[x + 1][y - 1] = a[x + 1][y + 1] = 1;
}
while(k--){
int x, y;
cin >> x >> y;
for(int i = x - 2; i <= x + 2; ++i)
for(int j = y - 2; j <= y + 2; ++j)
if(i > 0 && j > 0)
a[i][j] = 1;
}
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= n; ++j)
if(!a[i][j])
++ans;
cout << ans;
return 0;
}