zl程序教程

您现在的位置是:首页 >  其它

当前栏目

CSP 回收站选址 201912-2

CSP 回收站 选址
2023-09-27 14:20:54 时间

 思路:

还就是模拟就行,有点水了

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int n;
typedef pair<LL, LL> PLL;
map<PLL, int> mp;
vector<PLL> rp;
int a[5];
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++) {
        LL x, y;
        cin >> x >> y;
        mp[{x, y}] = 1;
        rp.push_back({ x,y });
    }
    for (int i = 0; i < rp.size();i++) {
        LL x = rp[i].first;
        LL y = rp[i].second;
        if (mp[{x + 1, y}] != 0 && mp[{x - 1, y}] != 0 && mp[{x, y+1}] != 0 && mp[{x, y-1}] != 0) {
            int count = 0;
            if (mp[{x + 1, y + 1}] != 0)count++;
            if (mp[{x + 1, y - 1}] != 0)count++;
            if (mp[{x - 1, y + 1}] != 0)count++;
            if (mp[{x - 1, y - 1}] != 0)count++;
            a[count]++;
        }
    }
    for (int i = 0; i < 5; i++) {
        cout << a[i] << endl;
    }
    return 0;
}