백준-10026번(적록색약)-python3
from collections import deque N=int(input()) canvas=[] for i in range(N): canvas.append(list(str(input()))) def dfs(x,y,color): q=deque([(x,y)]) while q: m,n=q.popleft() if color=='B': visit[x][y]=1 if color=='R' or color=='G': visit[x][y]=-1 for i,j in [(m+1,n),(m-1,n),(m,n+1),(m,n-1)]: if 0
2023. 11. 30.
백준-7576번(토마토)-python3
from collections import deque # M은 상자의 가로 칸의 수, N은 상자의 세로 칸 # 정수 1은 익은 토마토 # 정수 0은 익지 않은 토마토 # 정수 -1은 토마토가 들어있지 않은 칸 M,N=map(int,input().split()) box=[] visit=[[0 for ii in range(M)] for jj in range(N)] for _ in range(N): box.append(list(map(int,input().split()))) def bfs(): while q: x,y=q.popleft() for xx,yy in [(x+1,y),(x-1,y),(x,y+1),(x,y-1)]: if 0
2023. 11. 27.