import sysfrom collections import dequedirs = [(0, 1), (1, 0), (-1, 0), (0, -1)]board = []red,blue=[],[]N,M=0,0answer=sys.maxsizevisit=[]# 백트래킹def dfs(red,blue,count): global answer #종료지점 도착했는지 if board[red[0]][red[1]]==3 and board[blue[0]][blue[1]]==4: answer=min(answer,count) # 파란 수레가 이미 도착했다면 if board[blue[0]][blue[1]]==4: for i in range(4): rnr,rnc=red[0]+dir..