CCF 201912-2 回收站选址

#include <iostream>
#include <bits/stdc++.h>
#include <string>

using namespace std;

vector<Point> xy;
int a=0,b=0,c=0,d=0,e=0;

void isJudge(Point temp)
{
    int sum=0;
    int sum1=0;
    for(int i=0; i<xy.size(); i++)
    {
        if(xy[i].x==temp.x)
        {
            if(xy[i].y==temp.y+1||xy[i].y==temp.y-1)
                sum++;
        }
        else if(xy[i].y==temp.y)
        {
            if(xy[i].x==temp.x+1||xy[i].x==temp.x-1)
                sum++;
        }
        else
        {
            if( abs(xy[i].x-temp.x)==1 && abs(xy[i].y-temp.y)==1 )
                sum1++;
        }
    }
    if(sum==4)
    {
        switch (sum1)
        {
        case 0:
            a++;
            break;
        case 1:
            b++;
            break;
        case 2:
            c++;
            break;
        case 3:
            d++;
            break;
        case 4:
            e++;
            break;
        }

    }
}

int main()
{
    int number;
    cin>>number;
    while(number--)
    {
        Point temp;
        cin>>temp.x>>temp.y;
        xy.push_back(temp);
    }
    for(int i=0; i<xy.size(); i++)
    {
        isJudge(xy[i]);
    }
    cout<<a<<endl<<b<<endl<<c<<endl<<d<<endl<<e<<endl;
}

 

posted @ 2021-02-05 13:41  -Asurada-  阅读(127)  评论(0编辑  收藏  举报