[baekjoon] 7576. 토마토
코드 import collections N, M = map(int, input().split()) board = [list(map(int, input().split())) for _ in range(M)] near = [(0, -1), (0, 1), (1, 0), (-1, 0)] q = collections.deque() # 그냥 q로하니까 시간초과 떠서 deque로 수정 for i in range(M): for j in range(N): if board[i][j] == 1: q.append((i, j, 0)) board[i][j] = 2 while q: x, y, cnt = q.popleft() for a, b in near: xi, yi = x + a, y + b if 0 q = collection...
더보기