분기있는 bfs. 벽을 뿌순 횟수에 따라 분기를 나눠준다. import sys input = sys.stdin.readline from collections import deque def bfs(x,y): queue = deque() queue.append([x,y,0]) visited = [[[0]*(K+1) for _ in range(M)] for _ in range(N)] visited[x][y][0] = 1 while queue: x,y,b_cnt = queue.popleft() if x==N-1 and y==M-1: return visited[x][y][b_cnt] for i in range(4): nx = x + dx[i] ny = y + dy[i] if 0