
[백준] 2667번, 단지번호붙이기 (Python)
·
알고리즘/백준
문제 https://www.acmicpc.net/problem/2667 2667번: 단지번호붙이기 과 같이 정사각형 모양의 지도가 있다. 1은 집이 있는 곳을, 0은 집이 없는 곳을 나타낸다. 철수는 이 지도를 가지고 연결된 집의 모임인 단지를 정의하고, 단지에 번호를 붙이려 한다. 여 www.acmicpc.net 코드 import collections n = int(input()) graph = [list(map(int,input().strip())) for _ in range(n)] check = [[False]*n for _ in range(n)] def bfs(x,y): count = 1 check[x][y] = True queue = collections.deque() queue.append((..