[프로그래머스] Lv 2. [PCCP 기출문제] 2번 / 석유 시추
from collections import dequedef bfs(a, b, result, visited, land): dx = [0,0,1,-1] dy = [1,-1,0,0] n = len(land) m = len(land[0]) cnt = 0 visited[a][b] = 1 q = deque() q.append((a, b)) min_y, max_y = b, b while q: x, y = q.popleft() min_y = min(min_y, y) max_y = max(max_y, y) cnt += 1 for i in range(4): nx = x + dx[i] ..
2024. 7. 14.