[Python]CCF——第18次CCF认证题2(201912-2)

n = int(input())
a = []
dic = {0:0,1:0,2:0,3:0,4:0}
for i in range(n):
    a.append(list(map(int,input().split())))
for j in a:
    count = 4
    temp1 = [j[0],j[1]+1]
    temp2 = [j[0]+1,j[1]]
    temp3 = [j[0],j[1]-1]
    temp4 = [j[0]-1,j[1]]

    temp5 = [j[0]-1,j[1]+1]
    temp6 = [j[0]+1,j[1]+1]
    temp7 = [j[0]+1,j[1]-1]
    temp8 = [j[0]-1,j[1]-1]

    if temp1 in a and temp2 in a and temp3 in a and temp4 in a:
        if temp5 not in a:
            count -= 1
        if temp6 not in a:
            count -= 1
        if temp7 not in a:
            count -= 1
        if temp8 not in a:
            count -= 1
        dic[count] += 1

for i in range(5):
    print(dic[i])

猜你喜欢

转载自www.cnblogs.com/SavvyM/p/12053390.html