[백준 2206번] 벽 부수고 이동하기
from collections import deque n, m = map(int,input().split()) maze = [list(map(int,list(input()))) for _ in range(n)] visited = [[[0]*m for _ in range(n)] for _ in range(2)] dx = [-1,1,0,0] dy = [0,0,-1,1] def bfs(): visited[0][0][0] = 1 queue = deque([(0,0,0)]) while queue: w,x,y = queue.popleft() if x == n-1 and y == m-1: return visited[w][x][y] for i in range(4): nx = x + dx[i] ny = y + dy[i]..
2023. 8. 4.
[백준 14923번] 미로 탈출
from collections import deque dx = [-1,1,0,0] dy = [0,0,-1,1] n, m = map(int,input().split()) hx, hy = map(int,input().split()) ex, ey = map(int,input().split()) maze = [list(map(int,input().split())) for _ in range(n)] visited = [[[0]*m for _ in range(n)] for _ in range(2)] def bfs(): visited[0][hx-1][hy-1] = 0 queue = deque([(0,hx-1,hy-1)]) while queue: v = queue.popleft() w, x, y = v[0], v[1]..
2023. 8. 4.