思路:
还就是模拟就行,有点水了
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int n;
typedef pair<LL, LL> PLL;
map<PLL, int> mp;
vector<PLL> rp;
int a[5];
int main()
{
cin >> n;
for (int i = 0; i < n; i++) {
LL x, y;
cin >> x >> y;
mp[{x, y}] = 1;
rp.push_back({ x,y });
}
for (int i = 0; i < rp.size();i++) {
LL x = rp[i].first;
LL y = rp[i].second;
if (mp[{x + 1, y}] != 0 && mp[{x - 1, y}] != 0 && mp[{x, y+1}] != 0 && mp[{x, y-1}] != 0) {
int count = 0;
if (mp[{x + 1, y + 1}] != 0)count++;
if (mp[{x + 1, y - 1}] != 0)count++;
if (mp[{x - 1, y + 1}] != 0)count++;
if (mp[{x - 1, y - 1}] != 0)count++;
a[count]++;
}
}
for (int i = 0; i < 5; i++) {
cout << a[i] << endl;
}
return 0;
}