[백준/18290/파이썬] NM과 K (1)
소스코드 def dfs(x, y, d, s): global ans if d == K: ans = max(ans, s) return else: for i in range(x, N): for j in range(y if i == x else 0, M): if [i, j] not in q: if ([i + 1, j] not in q) and ([i - 1, j] not in q) and ([i, j + 1] not in q) and ([i, j - 1] not in q): q.append([i, j]) dfs(i, j, d + 1, s + a[i][j]) q.pop() N, M, K = map(int, input().split()) a = [list(map(int, input().split())) for _ ..