Code Viblo The Cross

Đề bài

Đáp án

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
import sys

count_line = 0
arr = []
for line in sys.stdin:
count_line += 1
if count_line == 1:
n = int(line)
else:
arr.append(list(line))

for i in range(1,n-1):
for j in range(1,n-1):
if arr[i][j] == '#' and arr[i - 1][j] == '#' and arr[i + 1][j] == '#' and arr[i][j-1] == '#' and arr[i][j+1] == '#':
arr[i][j] = '.'
arr[i + 1][j] = '.'
arr[i - 1][j] = '.'
arr[i][j + 1] = '.'
arr[i][j - 1] = '.'
for i in range(n):
for j in range(n):
if arr[i][j] == '#':
print('NO')
exit()
print("YES")