SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
def jung():
for i in range(N):
for j in range(N):
if arr[i][j] == '#':
idx[j] += 1
num = 0
lst = []
if len(set(idx)) == 2: # 0과 변의 길이 두 개만 있도록
for i in range(21):
if idx[i] != 0:
num = idx[i] # 가로의 길이
lst.append(i) # lst에 '#'이 있는 인덱스 모두 저장
else:
return 'no'
for i in range(len(lst) - 1):
if lst[i] != lst[i + 1] - 1: # '#'이 있는 인덱스가 하나씩 증가하는 형태가 아니면?
return 'no'
if (num % 2 == 0 and len(lst) % 2 != 0) or (num % 2 != 0 and len(lst) % 2 == 0): # 가로짝수+세로홀수 or 가로홀수+세로짝수 조합이면?
return 'no'
else:
return 'yes'
return 'no'
T = int(input())
for tc in range(1, T + 1):
N = int(input())
arr = [list(input()) for _ in range(N)]
idx = [0]*21 # '#'인 인덱스
print(f'#{tc} {jung()}')
'swea' 카테고리의 다른 글
11315. 오목 판정 (0) | 2023.08.28 |
---|---|
12733. 기지국 (0) | 2023.08.28 |
18575. 풍선팡 보너스 게임 (0) | 2023.08.28 |
1873. 상호의 배틀필드 (0) | 2023.08.27 |
2805. 농작물 수확하기 (0) | 2023.08.27 |