-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path12891번.py
More file actions
66 lines (58 loc) · 1.41 KB
/
12891번.py
File metadata and controls
66 lines (58 loc) · 1.41 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#DNA 비밀번호
checkList = [0] * 4
myList = [0] * 4
checkSecret = 0
def myadd(c):
global checkList, myList, checkSecret
if c == 'A':
myList[0] += 1
if myList[0] == checkList[0]:
checkSecret += 1
elif c == 'C':
myList[1] += 1
if myList[1] == checkList[1]:
checkSecret += 1
elif c == 'G':
myList[2] += 1
if myList[2] == checkList[2]:
checkSecret += 1
elif c == 'T':
myList[3] += 1
if myList[3] == checkList[3]:
checkSecret += 1
def myremove(c):
global checkList, myList, checkSecret
if c == 'A':
if myList[0] == checkList[0]:
checkSecret -= 1
myList[0] -= 1
elif c == 'C':
if myList[1] == checkList[1]:
checkSecret -= 1
myList[1] -= 1
elif c == 'G':
if myList[2] == checkList[2]:
checkSecret -= 1
myList[2] -= 1
elif c == 'T':
if myList[3] == checkList[3]:
checkSecret -= 1
myList[3] -= 1
S, P = map(int, input().split())
Result = 0
A = list(input())
checkList = list(map(int, input().split()))
for i in range(4):
if checkList[i] == 0:
checkSecret += 1
for i in range(P):
myadd(A[i])
if checkSecret == 4:
Result += 1
for i in range(P, S):
j = i - P
myadd(A[i])
myremove(A[j])
if checkSecret == 4:
Result += 1
print(Result)