제출 #521110

#제출 시각아이디문제언어결과실행 시간메모리
521110zaystevTracks in the Snow (BOI13_tracks)Cpython 3
컴파일 에러
0 ms0 KiB
from collections import deque m, n = map(int, input().strip().split()) grid = [] for _ in range(m): grid.append(list(input().strip())) q = deque([(0, 0)]) visited = set() costs = [[float("inf")] * n for _ in range(m)] costs[0][0] = 1 while q: x, y = q.popleft() if x == m - 1 and y == n - 1: return costs[x][y] visited.add((x, y)) for (dx, dy) in [(0, 1), (0, -1), (1, 0), (-1, 0)]: n_x, n_y = x + dx, y + dy if 0 <= n_x < m and 0 <= n_y < n and grid[n_x][n_y] != "." and (n_x, n_y) not in visited: loss = 0 if grid[n_x][n_y] == grid[x][y] else 1 if loss + costs[x][y] < costs[n_x][n_y]: costs[n_x][n_y] = loss + costs[x][y] q.append((n_x, n_y)) if loss == 1 else q.appendleft((n_x, n_y))

컴파일 시 표준 에러 (stderr) 메시지

File "tracks.py", line 17
    		return costs[x][y]
    		^
SyntaxError: 'return' outside function