Skip to content

Latest commit

 

History

History
37 lines (31 loc) · 847 Bytes

2630.md

File metadata and controls

37 lines (31 loc) · 847 Bytes

백준 2630번 색종이 만들기

2630


소스코드

  • 메모리 : 29200 KB
  • 시간 : 92 ms
def count(x, y, n):
    global white, blue
    color = matrix[x][y]
    for i in range(x, x+n):
        for j in range(y, y+n):
            if color != matrix[i][j]:
                count(x, y, n//2)
                count(x, y+n//2, n//2)
                count(x+n//2, y, n//2)
                count(x+n//2, y+n//2, n//2)
                return
    if color == 0 :
        white += 1
    else :
        blue += 1


n = int(input())
matrix = [list(map(int, input().split())) for i in range(n)]
white, blue = 0, 0
count(0,0,n)
print(white)
print(blue)