csp202009-2
"""
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
"""
import sys
def judgeInArea(xl,yd,xr,yu,x,y):
if x>=xl and x <= xr and y>=yd and y<= yu:
return '1'
else:
return '0'
def transferAddress(xl,yd,xr,yu,address):
i=0
result=[]
while i<len(address)/2:
result.append(judgeInArea(xl,yd,xr,yu,address[2*i],address[2*i+1]))
i+=1
return result
n,k,t,xl,yd,xr,yu=map(int,input().split())
# 连续k个,每人t时刻,n个人
data={}
i=1
while i<=n:
address=list(map(int,sys.stdin.readline().strip('\n').split()))
data[i]=transferAddress(xl,yd,xr,yu,address)
# 第i个人的位置,记录
i+=1
i=1
answer=[0,0]
while i<=n:
if (''.join(data[i])).find('1'*k) != -1:
answer[1]+=1
if '1' in data[i]:
answer[0]+=1
i+=1
print(answer[0])
print(answer[1])
用到了列表转字符串,用字符串函数,快速查找,相当于找公共子串
转载请注明原文地址:https://blackberry.8miu.com/read-9347.html