n = int(input())
dp = [[0] * n for i in range(n)]
dp[0][0] = 1
for i in range(n):
arr = list(map(int,input().split()))
for j in range(n):
if arr[j] != 0 and arr[j] + i < n:
dp[i + arr[j]][j] += dp[i][j]
if arr[j] != 0 and arr[j] + j < n:
dp[i][j + arr[j]] += dp[i][j]
print(dp[n - 1][n - 1])
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
48 ms |
18216 KB |
Output is correct |
2 |
Correct |
47 ms |
18220 KB |
Output is correct |
3 |
Correct |
50 ms |
18232 KB |
Output is correct |
4 |
Correct |
47 ms |
18136 KB |
Output is correct |
5 |
Correct |
46 ms |
18120 KB |
Output is correct |
6 |
Correct |
46 ms |
18116 KB |
Output is correct |
7 |
Correct |
50 ms |
18224 KB |
Output is correct |
8 |
Correct |
53 ms |
18216 KB |
Output is correct |
9 |
Correct |
59 ms |
19176 KB |
Output is correct |
10 |
Correct |
51 ms |
18172 KB |
Output is correct |
11 |
Correct |
49 ms |
18128 KB |
Output is correct |
12 |
Correct |
62 ms |
18192 KB |
Output is correct |
13 |
Correct |
60 ms |
19084 KB |
Output is correct |
14 |
Correct |
58 ms |
19092 KB |
Output is correct |
15 |
Correct |
86 ms |
21392 KB |
Output is correct |
16 |
Correct |
94 ms |
20396 KB |
Output is correct |
17 |
Correct |
82 ms |
19684 KB |
Output is correct |
18 |
Correct |
86 ms |
20576 KB |
Output is correct |
19 |
Correct |
94 ms |
20732 KB |
Output is correct |
20 |
Correct |
78 ms |
20452 KB |
Output is correct |