Created
March 3, 2020 05:50
-
-
Save inspirit941/308cb6b7465141334a9f1ba6276648ae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
n = int(sys.stdin.readline()) | |
maps = [list(map(int, sys.stdin.readline().split())) for _ in range(n)] | |
# 해당 좌표로 이동할 수 있는 방법의 개수 | |
table = [[0 for _ in range(n)] for _ in range(n)] | |
# 시작지점은 1로 정의 | |
table[0][0] = 1 | |
for y in range(n): | |
for x in range(n): | |
# 이전까지의 방법으로 도달할 수 있는 지점이면서, 다음 지점으로 이동할 수 있는 경우 (maps[y][x] != 0) | |
if table[y][x] != 0 and maps[y][x] != 0: | |
# 1. 아래쪽으로 이동할 수 있는 경우 | |
if y + maps[y][x] < n: | |
table[y + maps[y][x]][x] += table[y][x] | |
# 2. 오른쪽으로 이동할 수 있는 경우 | |
if x + maps[y][x] < n: | |
table[y][x+ maps[y][x]] += table[y][x] | |
print(table[-1][-1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment