[백준] 2206번 - 벽 부수고 이동하기 (파이썬)
# 벽 부수고 이동하기 import sys from collections import deque input = sys.stdin.readline N, M = map(int, input().split()) arr = [] for i in range(N): arr.append(list(map(int, input().strip()))) dx = [0, 1, 0, -1] dy = [1, 0, -1, 0] def bfs(): global result q = deque() q.append((0, 0, 0)) time = [[[0] * 2 for _ in range(M)] for _ in range(N)] time[0][0][0] = 1 while q: x, y, wall = q.popleft() if x == N-..
2022. 1. 23.
[백준] 1987번 - 알파벳 (파이썬)
# 알파벳 import sys input = sys.stdin.readline R, C = map(int, input().split()) arr = [] for _ in range(R): arr.append(list(input().strip())) dx = [0, 1, 0, -1] dy = [1, 0, -1, 0] result = 0 def move(): global result q = set([(0, 0, arr[0][0])]) while q: x, y, hist = q.pop() result = max(result, len(hist)) for k in range(4): nx = x + dx[k] ny = y + dy[k] if 0
2022. 1. 23.
[백준] 1062번 - 가르침 (파이썬)
# 가르침 import sys input = sys.stdin.readline N, K = map(int, input().split()) arr = [] for _ in range(N): arr.append(input().strip()) alpha = ['a', 'n', 't', 'i', 'c'] alpha_list = ['b', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'o', 'p', 'q', 'r', 's', 'u', 'v', 'w', 'x', 'y', 'z'] def choose_alpha(n, start): global result if n == 0: result = max(result, check()) return for i in range(start, ..
2022. 1. 22.
[백준] 1600번 - 말이 되고픈 원숭이 (파이썬)
# 말이 되고픈 원숭이 from collections import deque import sys input = sys.stdin.readline monkey_dx = [0, 1, 0, -1] monkey_dy = [1, 0, -1, 0] horse_dx = [-2, -1, 1, 2, 2, 1, -1, -2] horse_dy = [1, 2, 2, 1, -1, -2, -2, -1] def bfs(n): q = deque() q.append((0, 0, n)) count = [[[0] * (n + 1) for _ in range(M)] for _ in range(N)] while q: x, y, K = q.popleft() if x == N-1 and y == M-1: return count[x][y][K] ..
2022. 1. 21.