用了个笨方法写,利用map的性质解决问题,对每个点先遍历上下左右判断是否是可用的垃圾点,若可用则判断斜对角是否有点存在来计算垃圾站点的分数。此题过了,感觉有点虚。。。欢迎交流指正
#include<iostream>
#include<map>
#include<stdio.h>
using namespace std;
pair<long long int,long long int> point[1001];
map<pair<long long int,long long int>,int> pos;//is exist
//map<pair<int,int>,int> pt;//fenshu
int main(){
int ptcnt[5]={0,0,0,0,0};//
int n;
cin>>n;
pair<long long int,long long int> test;
for(int i=0;i<n;i++){
cin>>point[i].first>>point[i].second;
pos[point[i]]=2;
}
pair<long long int,long long int> suround[4];//up down left right
pair<long long int,long long int> suround2[4];//(x+-1,y+-1)
for(int i=0;i<n;i++){
//pt[point[i]]=0;
int cnt=0;//cnt=4???
suround[0].first=point[i].first;
suround[0].second=point[i].second+1;
suround[1].first=point[i].first;
suround[1].second=point[i].second-1;
suround[2].first=point[i].first-1;
suround[2].second=point[i].second;
suround[3].first=point[i].first+1;
suround[3].second=point[i].second;
for(int j=0;j<4;j++){
if(pos[suround[j]]==2){
cnt++;
//cout<<pos[suround[j]]<<",";
//cout<<endl;
}
}
//cout<<endl;
if(cnt==4)//useful
{
//pt[point[i]]=0;
int cu_pt=0;
suround2[0].first=point[i].first+1;
suround2[0].second=point[i].second+1;
suround2[1].first=point[i].first+1;
suround2[1].second=point[i].second-1;
suround2[2].first=point[i].first-1;
suround2[2].second=point[i].second-1;
suround2[3].first=point[i].first-1;
suround2[3].second=point[i].second+1;
for(int j=0;j<4;j++)
if(pos[suround2[j]]==2)
cu_pt++;
//cout
ptcnt[cu_pt]++;
}
}
for(int i=0;i<5;i++)
cout<<ptcnt[i]<<endl;
return 0;
}