一二三四五 上山打老虎

CCF-CSP-2019-12-2回收站选址

题目链接:http://118.190.20.162/submitlist.page?gpid=T99

代码

#include<bits/stdc++.h>

using namespace std;
int dx[]={0,-1,1,0};
int dy[]={-1,0,0,1};
int dxp[]={1,-1,1,-1};
int dyp[]={-1,1,1,-1};
map<pair<int,int>,int>mp;
struct node{
    int x,y;
    node(int _x,int _y):x(_x),y(_y){}
};
vector<node> ve;
int a[5];
int main (){
    int n;
    cin>>n;
    int l,r;
    for(int i=0;i<n;i++){
        cin>>l>>r;
        ve.push_back(node(l,r));
        mp[make_pair(l,r)]=1;
    }
    for(int i=0;i<ve.size();i++){
        l=ve[i].x;
        r=ve[i].y;
        int atm=0,ans=0;
        for(int j=0;j<4;j++){
            if(mp.find(make_pair(l+dx[j],r+dy[j]))!=mp.end())atm++;
            if(mp.find(make_pair(l+dxp[j],r+dyp[j]))!=mp.end())ans++;
        }
        if(atm==4)
        a[ans]++;
    }
    for(int i=0;i<=4;i++){
        cout<<a[i]<<endl;
    }
    return 0;
}
/*
7
1 2
2 1
0 0
1 1
1 0
2 0
0 1


2
0 0
-100000 10

11
9 10
10 10
11 10
12 10
13 10
11 9
11 8
12 9
10 9
10 11
12 11
*/

posted @ 2021-03-16 12:37  黒川川  阅读(50)  评论(0)    收藏  举报