AcWing 3283. 回收站选址
原题链接
简单
作者:
Value
,
2021-04-09 15:29:14
,
所有人可见
,
阅读 376
#include <iostream>
#include <cstdio>
using namespace std;
const int N = 1010;
typedef long long ll;
typedef pair<ll, ll> pii;
pii t[N];
int n;
int score[5];
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
int px[] = {-1, -1, 1, 1};
int py[] = {-1, 1, -1, 1};
int get_score(pii g){
int cnt = 0;
for(int i = 0; i < 4; i ++ ){
int xx = g.first + dx[i];
int yy = g.second + dy[i];
for(int j = 0; j < n; j ++ ){
if(t[j].first == xx && t[j].second == yy){
cnt ++ ;
break;
}
}
}
if(cnt != 4) return -1;
cnt = 0;
for(int i = 0; i < 4; i ++ ){
int xx = g.first + px[i];
int yy = g.second + py[i];
for(int j = 0; j < n; j ++ ){
if(t[j].first == xx && t[j].second == yy) cnt ++ ;
}
}
return cnt;
}
int main(){
cin >> n;
for(int i = 0; i < n; i ++ ) scanf("%lld%lld", &t[i].first, &t[i].second);
for(int i = 0; i < n; i ++ ){
int index = get_score(t[i]);
if(index != -1) score[index] ++ ;
}
for(int i = 0; i < 5; i ++ ) cout << score[i] << endl;
return 0;
}