목록2024/01/22 (2)
JiSoo's Devlog
from collections import deque n, m = map(int, input().split()) g = [] dx = [-1, 1, 0, 0] dy = [0, 0, -1, 1] for _ in range(n): g.append(list(map(int, input()))) def bfs(x, y): q = deque() q.append((x, y)) while q: x, y = q.popleft() for i in range(4): nx = x + dx[i] ny = y + dy[i] if nx = n or ny = m: continue if g[nx][ny] == 0: continue if g[nx][ny] == 1: g[nx][ny] = g[x][..
from collections import deque n, m = map(int, input().split()) g = [] dx = [-1, 1, 0, 0] dy = [0, 0, -1, 1] for _ in range(n): g.append(list(map(int, input()))) def bfs(x, y): q = deque() q.append((x, y)) while q: x, y = q.popleft() for i in range(4): nx = x + dx[i] ny = y + dy[i] if nx = n or ny = m: continue if g[nx][ny] == 0: continue if g[nx][ny] == 1: g[nx][ny] = g[x][..