forked from ngthanhtrung23/CompetitiveProgramming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ.py
More file actions
36 lines (31 loc) · 893 Bytes
/
J.py
File metadata and controls
36 lines (31 loc) · 893 Bytes
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
n, need = map(int, raw_input().split())
a = raw_input()
f = [[[False for i in xrange(2)] for j in xrange(111)] for k in xrange(111)]
if need == 0:
f[0][0][1] = True
else:
f[0][0][0] = True
for i in xrange(n):
for j in xrange(i+1):
for k in xrange(2):
if f[i][j][k]:
i2 = i + 1
if a[i] == 'Y' or a[i] == '?':
j2 = 0
k2 = k
f[i2][j2][k2] = True
if a[i] == 'N' or a[i] == '?':
j2 = j + 1
if j2 <= need:
k2 = k
if j2 == need:
k2 = 1
f[i2][j2][k2] = True
res = False
for j in xrange(need + 1):
if f[n][j][1]:
res = True
if res:
print 'YES'
else:
print 'NO'