๋ฌธ์
https://www.acmicpc.net/problem/2630
ํ์ด
# ๋ฐฑ์ค 2630๋ฒ ๋ฌธ์ - ์์ข
์ด ๋ง๋ค๊ธฐ
n = int(input())
graph = [list(map(int, input().split())) for _ in range(n)]
result = []
def solution(x, y, n):
half = n // 2
color = graph[x][y]
for i in range(x, x+n):
for j in range(y, y+n):
if color != graph[i][j]:
solution(x,y,half)
solution(x,y+half,half)
solution(x+half,y,half)
solution(x+half,y+half,half)
return
if color == 0:
result.append(0)
else:
result.append(1)
solution(0,0,n)
print(result.count(0))
print(result.count(1))
๋ถํ ์ ๋ณต์ด ์ต์ํ์ง ์์์ ์๊ฐ์ด ์๊พธ ์ค๋ ๊ฑธ๋ฆฐ๋ค..
'๐๏ธ Algorithm > ๐ฉ ๋ฐฑ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๐ฉ [๋ฐฑ์ค] [Python] [Class3] 1389๋ฒ_์ผ๋น ๋ฒ ์ด์ปจ์ 6๋จ๊ณ ๋ฒ์น (0) | 2022.11.10 |
---|---|
๐ฉ [๋ฐฑ์ค] [Python] 12865๋ฒ_ํ๋ฒํ ๋ฐฐ๋ญ (0) | 2022.11.09 |
๐ฉ [๋ฐฑ์ค] [Python] 2468๋ฒ_์์ ์์ญ (1) | 2022.11.09 |
๐ฉ [๋ฐฑ์ค] [Python] 2193๋ฒ_์ด์น์ (0) | 2022.11.08 |
๐ฉ [๋ฐฑ์ค] [Python] [BFS] 7576๋ฒ_ํ ๋งํ (0) | 2022.11.07 |