题目链接

#include <iostream>
#include <map>
using namespace std;
int n;
int score[5] = {0};
int select(map< pair<int,int> , int>mp,pair<int,int>h){
int sum = 0;
pair<int,int>t[4];
t[0].first = h.first + 1; t[0].second = h.second;
t[1].first = h.first; t[1].second = h.second + 1;
t[2].first = h.first - 1; t[2].second = h.second;
t[3].first = h.first; t[3].second = h.second - 1;
if(mp[t[0]] == 1 && mp[t[1]] == 1 && mp[t[2]] == 1 && mp[t[3]] == 1)
{
t[0].first = h.first + 1; t[0].second = h.second + 1;
t[1].first = h.first + 1; t[0].second = h.second - 1;
t[2].first = h.first - 1; t[2].second = h.second + 1;
t[3].first = h.first - 1; t[3].second = h.second - 1;
for (int i = 0; i < 4; ++i) {
if(mp[t[i]] == 1)
sum++;
}
return sum;
}
return -1;
}
int main() {
ios::sync_with_stdio(false);
cin>>n;
pair<int,int>h[n];
map<pair<int,int>,int>mp;
string str;
for (int i = 0; i < n; ++i) {
cin>>h[i].first>>h[i].second;
mp[h[i]] = 1;
}
for (int i = 0; i < n; ++i) {
int res = select(mp,h[i]);
if (res != -1)
score[res]++;
}
for (int i = 0; i < 5; ++i) {
cout<<score[i]<<endl;
}
return 0;
}
