1012
-
[백준 1012번] 유기농 배추Coding Test/백준 2021. 1. 4. 21:51
# 문제 내 풀이 - DFS와 BFS로 모두 구현해 봄 from collections import deque # bfs를 위한 큐 생성 라이브러리 import sys sys.setrecursionlimit(10000) # 파이썬 재귀 한도를 10000으로 늘림 (기존 재귀 한도: 1000) # dfs 정의 def dfs(x, y): graph[x][y] = -1 dx = [0, -1, 0, 1] dy = [1, 0, -1, 0] for i in range(4): next_x = x + dx[i] next_y = y + dy[i] if next_x = n or next_y = m: continue if graph[next_x][next_y] == 1: ..