[파이썬] 백준 27211 : 도넛 행성 (골드5)
[파이썬] 백준 27211 : 도넛 행성 (골드5)백준 27211 : 도넛 행성 (골드5)풀이방향성 생각영역의 개수를 BFS/DFS로 세주기.영역 범위를 벗어나면 %연산을 통해서 영역 내부로 처리해주기.파이썬from collections import dequeimport sysinput = sys.stdin.readlinedires = [(1,0),(0,1),(-1,0),(0,-1)]H,W = map(int,input().split())arr = [list(map(int,input().split())) for _ in range(H)]V = [[False]*W for _ in range(H)]def bfs(x,y): V[y][x] = True Q = deque([(x,y)]) while ..
2025. 4. 24.