- 메모리 : 30864 KB
- 시간 : 76 ms
def solution(x, y, n):
check = matrix[x][y]
for i in range(x,x+n):
for j in range(y,y+n):
if check != matrix[i][j]:
print('(', end='')
solution(x,y,n//2)
solution(x,y+n//2,n//2)
solution(x+n//2,y,n//2)
solution(x+n//2,y+n//2,n//2)
print(')', end='')
return
if check == 0:
print('0',end='')
return
else:
print('1',end='')
return
n = int(input())
matrix = [list(map(int,input())) for i in range(n)]
solution(0,0,n)