CCF 201912-2 回收站选址
程序员文章站
2022-06-25 15:06:00
#include #include #include #include #include #include
#include <cstring>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <unordered_map>
#include <map>
#define ll long long
#define PII pair<int, int>
using namespace std;
#define TLE ios::sync_with_stdio(0),cin.tie(0)
const int INF = 0x3f3f3f3f;
#define mod 1000000007
int main() {
TLE;
PII a[1005];
int n;
cin >> n;
map<PII, int> mp;
for (int i = 0; i < n; i++) {
double xt, yt;
cin >> xt >> yt;
if (xt == (int)xt && yt == (int)yt) a[i] = make_pair((int)xt, (int)yt);
mp[make_pair(a[i].first, a[i].second)] = 1;
}
int ans[5] = { 0 }, f1[4] = { 0,1,0,-1 }, f2[4] = { 1,0,-1,0 };
int F1[4] = { 1,-1,1,-1 }, F2[4] = { 1,-1,-1,1 };
for (int i = 0; i < n; i++) {
PII t = a[i]; int flag = 1;
for (int j = 0; j < 4; j++)
if (!mp[make_pair(a[i].first + f1[j], a[i].second + f2[j])])
flag = 0;
if (flag) {
int temp = 0;
for (int j = 0; j < 4; j++)
if (mp[make_pair(a[i].first + F1[j], a[i].second + F2[j])])
temp++;
ans[temp]++;
}
}
for (int i = 0; i < 5; i++)
cout << ans[i] << endl;
}
本文地址:https://blog.csdn.net/weixin_45919985/article/details/108150729