0
点赞
收藏
分享

微信扫一扫

201912-2 回收站选址

吃面多放酱 2022-03-12 阅读 142

文章目录

201912-2 回收站选址

1. 题目介绍

  • 本题网址:http://118.190.20.162/view.page?gpid=T99
  • 本题截图:
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

2. Python代码

n = int(input()) # 已查明的垃圾点个数
I = [0]*n # 垃圾点的坐标集合
H = [] # 回收站坐标
C = [] # 得分集合
for i in range(n):
    I[i] = list(map(int, input().split()))
for i in range(n):
    x=I[i][0]
    y=I[i][1]
    if [x+1,y] in I and [x,y+1] in I and [x-1,y] in I and [x,y-1] in I:
        H.extend([I[i]])
for h in H:
    count = 0 # 得分初始为0
    x = h[0]
    y = h[1] 
    if [x+1,y+1] in I:       
        count += 1
    if [x+1,y-1] in I:
        count += 1
    if [x-1,y-1] in I:
        count += 1
    if [x-1,y+1] in I:
        count += 1
    C.extend([count])    
print(C.count(0))
print(C.count(1))
print(C.count(2))
print(C.count(3))
print(C.count(4))

3.测试结果:

在这里插入图片描述

  • 总结:小白刚刚接触csp,若代码算法关于简单,过于暴力望谅解
举报

相关推荐

0 条评论