
[파이썬/python] 백준 1795 - 마알
·
Algorithm
import sys, math from collections import deque dx = [1, 1, -1, -1, 2, -2, 2, -2] dy = [2, -2, 2, -2, 1, 1, -1, -1] path = [] N, M = map(int, sys.stdin.readline().split()) for i in range(N): temp = sys.stdin.readline().rstrip() temp_arr = [] for j, each in enumerate(temp): if each == '.': temp_arr.append(0) else: temp_arr.append(int(each)) path.append(temp_arr) deq = deque() def bfs(x, y): deq.ap..