-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathP2508.py
40 lines (28 loc) · 1.03 KB
/
P2508.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
36
37
38
39
40
def is_candy(a, b, c, xy):
return (a == '>' and b == 'o' and c == '<' and xy == 'x') or \
(a == 'v' and b == 'o' and c == '^' and xy == 'y')
if __name__ == '__main__':
test_count = int(input())
for _ in range(test_count):
input()
height = int(input().split()[0])
candy = 0
tmp = [
# line_number: [first_word, second_word, third_word]
[] for x in range(401)
]
for y in range(height):
line = input()
for x in range(len(line)):
if line[x] == '>' and len(line) > x + 2:
if is_candy(line[x], line[x + 1], line[x + 2], 'x'):
candy += 1
if line[x] == 'v':
tmp[x] = ['v']
else:
tmp[x].append(line[x])
if len(tmp[x]) == 3:
if is_candy(tmp[x][0], tmp[x][1], tmp[x][2], 'y'):
candy += 1
tmp[x] = []
print(candy)