思路
本来想用dfs来着,有垃圾的地方就标一后来看到数的大小为,数量却只有就果断暴力了…
Code
#include<bits/stdc++.h>//暴力枚举
using namespace std;
typedef long long ll;
ll x[1010], y[1010], num[1010], score[1010], ans[10];
int main()
{
int n;
cin >> n;
for (int i = 1; i <= n; i++)//录入地址
cin >> x[i] >> y[i];
for(int i=1;i<=n;i++)
for (int j = i + 1; j <= n; j++)
if (x[i] == x[j] && y[i] == y[j] - 1 || x[i] == x[j] && y[i] == y[j] + 1 || x[i] == x[j] + 1 && y[i] == y[j] || x[i] == x[j] - 1 && y[i] == y[j])//暴力枚举
{
num[j]++;
num[i]++;
}
for (int i = 1; i <= n; i++)
if (num[i] == 4)//符合选址要求
for (int j = 1; j <= n; j++)
if (x[j] == x[i] - 1 && y[j] == y[i] - 1 || x[j] == x[i] - 1 && y[j] == y[i] + 1 || x[j] == x[i] + 1 && y[j] == y[i] + 1 || x[j] == x[i] + 1 && y[j] == y[i] - 1)
score[i]++;
for (int i = 1; i <= n; i++)
if (num[i] == 4)
ans[score[i]]++;
for (int i = 0; i <= 4; i++)
cout << ans[i] << endl;
return 0;
}