-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweek04_3.py
More file actions
38 lines (35 loc) · 855 Bytes
/
week04_3.py
File metadata and controls
38 lines (35 loc) · 855 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
37
38
import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n, m = map(int, input().split())
world = input().rstrip()
blank = input()
start = world.index("@")
end = world.index("O")
rock = world.index("G")
up = 1 if start < rock else -1
count = 0
for i in range(start, rock, up):
if world[i] == '#':
count += 1
if count > m:
break
else:
continue
if count <= m:
print("YES")
else:
count = 0
up = 1 if start < end else -1
for i in range(start, end, up):
if world[i] == '#':
count += 1
if count > m:
break
else:
continue
if count > m:
print("NO")
else:
print("YES")