CCF 201912-02 回收站选址 Python

在这里插入图片描述在这里插入图片描述
在这里插入图片描述

"""
1.x、y为整数
2.(x,y)上下左右均有垃圾
满足上述两个条件后根据(x,y)4个角上的垃圾数进行评分(最多4分)
"""
'''
测试用例
7
1 2
2 1
0 0
1 1
1 0
2 0
0 1
'''
n = int(input())
L = []
scoreList = [0]*5
for i in range(n):
    (x,y) = map(str, input().split())
    # 需要判断是否为整数
    if '.' not in x and '.' not in y:
        x = int(x)
        y = int(y)
        L.append((x,y))
for (x,y) in L:
    if (x-1, y) in L and (x+1, y) in L and (x, y-1) in L and (x,y+1) in L:
        score = 0
        if (x-1,y-1) in L:
            score += 1
        if (x-1,y+1) in L:
            score += 1
        if (x+1,y-1) in L:
            score += 1
        if (x+1,y+1) in L:
            score += 1
        scoreList[score] += 1
for i in range(5):
    print(scoreList[i])

满分程序!

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值