题目
代码
#pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 55;
unordered_set<int> s;
int n, L, S;
int g[N][N];
bool check(int r, int c)
{
for(int i = 0; i <= S; i++)
{
for(int j = 0; j <= S; j++)
{
if(g[i][j] ^ s.count((i+r-S)*(L+1) + j+c) == 1) return false;
}
}
return true;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> L >> S;
for(int i = 1; i <= n; i++)
{
int r, c;
cin >> r >> c;
s.insert((L-r)*(L+1) + c);
}
for(int i = 0; i <= S; i++)
{
for(int j = 0; j <= S; j++)
{
cin >> g[i][j];
}
}
int cnt = 0;
for(auto tree : s)
{
int r = tree / (L+1), c = tree % (L+1);
if(r - S < 0 || c + S > L) continue;
if(check(r, c)) cnt++;
}
cout << cnt;
return 0;
}