SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
단순 구현문제
t = int(input())
for tc in range(1,t+1):
n,k = list(map(int,input().split()))
arr = [list(map(int,input().split()))for _ in range(n)]
answer = 0
# 가로로 탐색
for y in range(n):
cnt = 0
for x in range(n):
if arr[y][x] ==0:
if cnt ==k:
answer +=1
cnt =0
continue
else:
cnt +=1
if cnt ==k:
answer +=1
#세로로 탐색
for x in range(n):
cnt = 0
for y in range(n):
if arr[y][x] ==0:
if cnt ==k:
answer +=1
cnt = 0
continue
else:
cnt +=1
if cnt ==k:
answer +=1
print(f"#{tc} {answer}")
'Algorithm > swea' 카테고리의 다른 글
[파이썬]swea 1970: 쉬운 거스름돈 (0) | 2023.02.05 |
---|---|
[파이썬]swea 1976: 시각 덧셈 (1) | 2023.02.04 |
[파이썬]swea 2001: 파리 퇴치 (0) | 2023.02.02 |
[파이썬]swea 15758: 무한 문자열 (0) | 2023.02.02 |
[파이썬]swea 2005: 파스칼의 삼각형 (0) | 2023.02.01 |
댓글