CCF认证考试题解目录
C++题解
直接模拟就行了!主要提高自己对STL库的熟练程度!参考海岛Blog大佬!自己的实现方法实在是小学生,不,可能连小学生都不如,┭┮﹏┭┮!**第一行输入的是垃圾的个数,接下来的是每个垃圾的坐标,输出不同分数的垃圾个数。**简单模拟。
#include<bits/stdc++.h>
using namespace std;
const int maxn=1010;
pair<int,int> p[maxn];
map<pair<int,int>,int> mp;
int d[5];
int main()
{
int n;
scanf("%d",&n);
for(int i=0; i<n; i++)
{
int x,y;
scanf("%d %d",&x,&y);
p[i]=make_pair(x,y);
mp[p[i]]=1;
}
for(int i=0; i<n; i++)
{
int x=p[i].first;
int y=p[i].second;
if(mp[make_pair(x,y-1)]&&mp[make_pair(x,y+1)]&&mp[make_pair(x-1,y)]&&mp[make_pair(x+1,y)])
d[mp[make_pair(x-1,y-1)]+mp[make_pair(x+1,y+1)]+mp[make_pair(x-1,y+1)]+mp[make_pair(x+1,y-1)]]++;
}
for(int i=0; i<5; i++) printf("%d\n",d[i]);
return 0;
}