n = int(input())
loc_list = []
for i in range(n):
a = input().split(' ')
a1 = int(a[0])
a2 = int(a[1])
loc_list.append([a1,a2])
#检查邻居位置是否存在垃圾
def check_loc(loc,loc_list):
x = loc[0]
y = loc[1]
if [x-1,y] in loc_list and [x,y-1] in loc_list and [x+1,y] in loc_list and [x,y+1] in loc_list: #逆时针方向判断
return 1
else:
return 0
#检查角落位置是否存在垃圾,并计数
def count_one(loc,loc_list):
corner_num = 0
x = loc[0]
y = loc[1]
if [x-1,y+1] in loc_list: #逆时针方向判断
corner_num +=1
if [x-1,y-1] in loc_list:
corner_num +=1
if [x+1,y-1] in loc_list:
corner_num +=1
if [x+1,y+1] in loc_list:
corner_num +=1
return corner_num
def count_all(loc_num,count_all_num):
if loc_num == 0:
count_all_num[0] +=1
elif loc_num == 1:
count_all_num[1] +=1
elif loc_num == 2:
count_all_num[2] +=1
elif loc_num == 3:
count_all_num[3] +=1
elif loc_num == 4:
count_all_num[4] +=1
return count_all_num
count_all_num = []
for i in range(5):
count_all_num.append(0)
for i in range(n):
loc_status = check_loc(loc_list[i],loc_list)
if loc_status == 1:
loc_num = count_one(loc_list[i],loc_list)
count_all_num = count_all(loc_num,count_all_num)
for i in range(5):
print(count_all_num[i])
流程图如下