CCF 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
样例输出
3
2
样例输入
1 3 8 0 0 10 10
-1 -1 0 0 0 0 -1 -1 0 0 -1 -1 0 0 0 0
样例输出
1
0
满分证明
解题思路
连续K和或多个,在区域内(判断连续 加一个标志位就好了)。是解题的关键;中间break是为了加快运算;只要逗留,就一定是经过的(经过高危区域的人数大于曾在高危区域逗留的人数)。
满分代码
满分代码一
n
, k
, t
, xl
, yd
, xr
, yu
= map(int, input().split
())
jg_count
= 0
dl_count
= 0
for i
in range(n
):
lx_flag
= 0
jg_flag
= 0
temp_jg_count
= 0
temp
= list(map(int, input().split
()))
for j
in range(len(temp
) // 2):
if (temp
[2 * j
] <= xr
) & (temp
[2 * j
] >= xl
) & (temp
[2 * j
+ 1] <= yu
) & (temp
[2 * j
+ 1] >= yd
):
lx_flag
= 1
jg_flag
= 1
if lx_flag
== 1:
temp_jg_count
+= 1
else:
lx_flag
= 0
temp_jg_count
= 0
if temp_jg_count
>= k
:
dl_count
+= 1
break
if jg_flag
== 1:
jg_count
+= 1
print(jg_count
)
print(dl_count
)
满分代码二
def is_in(xl
, yd
, xr
, yw
, xx
, yy
):
return (xl
<= xx
<= xr
) & (yd
<= yy
<= yw
)
n
, k
, t
, xl
, yd
, xr
, yw
= map(int, input().split
())
jg
= 0
dl
= 0
for _
in range(n
):
ll
= list(map(int, input().split
()))
j_flag
= 0
d_flag
= 0
for i
in range(t
):
if is_in
(xl
, yd
, xr
, yw
, ll
[2 * i
], ll
[2 * i
+ 1]):
j_flag
= 1
d_flag
= d_flag
+ 1
else:
d_flag
= 0
if d_flag
== k
:
dl
= dl
+ 1
break;
if j_flag
== 1:
jg
= jg
+ 1
print(jg
)
print(dl
)