-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path服药.py
38 lines (31 loc) · 885 Bytes
/
服药.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
n = int(input())
init_sam = input()
m = int(input())
sub = []
add = []
for i in range(m):
sub.append(input())
add.append(input())
q = int(input())
eat = []
for i in range(q):
eat.append(int(input())-1)
for i in range(q):
a = []
for j in range(n): #吃药后治好的情况
if init_sam[j] == '0' and sub[eat[i]][j] == '0':
a.append('0')
if init_sam[j] == '1' and sub[eat[i]][j] == '0':
a.append('1')
if sub[i][j] == '1':
a.append('0')
new_samp = []
for j in range(n): #吃药后治好的情况
if a[j] == '1' and add[eat[i]][j] == '0':
new_samp.append('1')
if a[j] == '0' and add[eat[i]][j] == '0':
new_samp.append('0')
if add[eat[i]][j] == '1':
new_samp.append('1')
init_sam = new_samp
print(sum(list(map(int,new_samp))))