간단한 재귀문제였다.
짜잔
N = int(input())
arr = []
for _ in range(N):
arr.append(list(map(int, input().split())))
ans = [0, 0]
def solve(i, j, N):
if N == 1:
if arr[i][j] == 0:
ans[0] += 1
return
else:
ans[1] += 1
return
for r in range(N):
for c in range(N):
if arr[i][j] != arr[i + r][j + c]:
solve(i, j, N // 2)
solve(i + N // 2, j, N // 2)
solve(i, j + N // 2, N // 2)
solve(i + N // 2, j + N // 2, N // 2)
return
ans[arr[i][j]] += 1
return
solve(0, 0, N)
print(ans[0])
print(ans[1])