global w, b
w = 0
b = 0
def check(list, size):
c = 0
for i in range(size):
a = 0
for j in range(size):
a += list[i][j]
if a == size:
c += 1
if a != 0 and a != size:
return False
elif a == 0 and c != 0:
return False
if c == 0:
return 'w'
else:
return 'b'
def quad(list1, size):
global w, b
s = int(size / 2)
if check(list1, size) == 'w':
w += 1
elif check(list1, size) == 'b':
b += 1
else:
paper1 = []
paper2 = []
paper3 = []
paper4 = []
for i in range(0, s):
paper1.append(list1[i][:s])
paper2.append(list1[i][s:])
paper3.append(list1[s+i][:s])
paper4.append(list1[s + i][s:])
quad(paper1, s)
quad(paper2, s)
quad(paper3, s)
quad(paper4, s)
size = int(input())
paper = []
for i in range(size):
list1 = list(map(int, input().split()))
paper.append(list1)
quad(paper, size)
print(w)
print(b)
hys3835 3년 전
도와주십시오 ㅠㅠㅠ 어떤 문제가 있는지 아무리 고민해봐도 잘 모르겠습니다.