[알고리즘] 백준 - 점프

June·2021년 8월 19일
0

알고리즘

목록 보기
235/260

백준 - 점프

옛날 내 풀이

dx = [1, 0]
dy = [0, 1]

n = int(input())
graph = [list(map(int, input().split())) for _ in range(n)]
dp = [ [0]*n for _ in range(n)]
dp[0][0] = 1
for i in range(n):
    for j in range(n):
        if i == n-1 and j == n-1:
            break

        if i + graph[i][j] < n:
            dp[i + graph[i][j]][j] += dp[i][j]

        if j + graph[i][j] < n:
            dp[i][j + graph[i][j]] += dp[i][j]

print(dp[n-1][n-1])

이번에 DFS를 시도하다가 시간이 터졌다. 예전에 쉽게 푼건데도 안풀린다.

0개의 댓글