天天看点

ccf csp 202009-2风险人群筛查(python)

历年题解 CCF CSP历年题解(python)

ccf csp 202009-2风险人群筛查(python)
ccf csp 202009-2风险人群筛查(python)

样例输入:

5 2 6 20 40 100 80

100 80 100 80 100 80 100 80 100 80 100 80

60 50 60 46 60 42 60 38 60 34 60 30

10 60 14 62 18 66 22 74 26 86 30 100

90 31 94 35 98 39 102 43 106 47 110 51

0 20 4 20 8 20 12 20 16 20 20 20

1 3 8 0 0 10 10

-1 -1 0 0 0 0 -1 -1 0 0 -1 -1 0 0 0 0

题目链接: 202009-2风险人群筛查

问题分析:

对每行坐标处理,若有坐标在高危区域则经过,在sum列表中存储连续坐标的个数,若sum中最大值>=k则为逗留

满分例程:

n,k,t,xl,yd,xr,yr=map(int,input().split())
jg,dl=0,0
for i in range(n):
    l=list(map(int,input().split()))
    bl=False#判断是否连续
    bn=False#判断是否经过
    num=[]#存储每次连续的个数
    con=1#连续的次数
    for j in range(t):
        if xl<=l[2*j]<=xr and yd<=l[2*j+1]<=yr:#在高危区域内
            bn=True#经过
            if bl==True:#前一个坐标也经过
                con+=1
            else:
                num.append(con)
                con=1
            bl=True
        else:
            bl=False
    num.append(con)
    if bn==True:
        jg+=1
    if max(num)>=k:
        dl+=1
print(jg)
print(dl)