2667
-
[백준 2667번] 단지번호붙이기Coding Test/백준 2021. 1. 4. 21:44
# 문제 내 풀이 1 n = int(input()) graph = [list(map(int, input())) for _ in range(n)] # dfs 정의 def dfs(x, y, cnt): if x = n or y = n: return cnt if graph[x][y] == 1: graph[x][y] = -1 cnt += 1 cnt = dfs(x - 1, y, cnt) cnt = dfs(x + 1, y, cnt) cnt = dfs(x, y - 1, cnt) cnt = dfs(x, y + 1, cnt) return cnt return cnt h_cnt = 0 # 단지 개수 h_list = [] # 각 단지의 집의 개수 for i in range(n): for j ..