首页 > 编程语言 > 详细

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

时间:2019-12-17 11:58:37      阅读:164      评论:0      收藏:0      [点我收藏+]
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])

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

原文:https://www.cnblogs.com/SavvyM/p/12053390.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!