[백준] 2573번 - 빙산 (파이썬)
# 빙산 from collections import deque import sys input = sys.stdin.readline N, M = map(int, input().split()) arr = [] ice = [] melt = [] for i in range(N): arr.append(list(map(int, input().split()))) for j in range(M): if arr[i][j] != 0: ice.append((i, j)) dx = [0, 1, 0, -1] dy = [1, 0, -1, 0] def melt_check(): for x, y in ice: if arr[x][y] != 0: zero = 0 for k in range(4): nx = x + dx[k] ny = y + ..
2022. 1. 25.
[백준] 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.