A - Яблов и простая задача

public
yeskendir.sultanov Apr 26, 2024 Never 52
Clone
Python 33.py 22 lines (17 loc) | 530 Bytes
1
n = int(input())
2
table = [input() for i in range(n)]
3
4
result = 'YES'
5
6
for i in range(n):
7
for j in range(n):
8
cnt = 0
9
10
if i - 1 >= 0 and table[i - 1][j] == 'o':
11
cnt += 1
12
if i + 1 < n and table[i + 1][j] == 'o':
13
cnt += 1
14
if j - 1 >= 0 and table[i][j - 1] == 'o':
15
cnt += 1
16
if j + 1 < n and table[i][j + 1] == 'o':
17
cnt += 1
18
19
if cnt % 2 != 0:
20
result = 'NO'
21
22
print(result)