이호진

swea 1979 - 어디에 단어가 들어갈 수 있을까 - 2021/05/12 본문

SWEA문제풀이

swea 1979 - 어디에 단어가 들어갈 수 있을까 - 2021/05/12

이호진 2021. 5. 12. 12:21
T = int(input())
for test_case in range(1, T + 1):
	n,m=map(int,input().split())
	graph=[]
	for i in range(n):
		graph.append(list(map(int,input().split())))
	count=0
	for i in range(n):
		current=0
		for j in range(n):
			if graph[i][j]==1:
				current+=1
			if graph[i][j]==0 or j==n-1:
				if current==m:
					count+=1
				current=0
		for j in range(n):
			if graph[j][i]==1:
				current+=1
			if graph[j][i]==0 or j==n-1:
				if current==m:
					count+=1
				current=0
	print('#%d %d'%(test_case,count))