n = int(input())
g = []
dp = []
for _ in range(n):
g.append([int(x) for x in input().split()])
dp.append([0] * n)
dp[0][0] = 1
for i in range(n):
for j in range(n):
if i < n-1 and i + g[i][j] < n:
dp[i+g[i][j]][j] += dp[i][j]
if j < n-1 and j + g[i][j] < n:
dp[i][j+g[i][j]] += dp[i][j]
print(dp[n-1][n-1])
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
2796 KB |
Output is correct |
2 |
Correct |
17 ms |
2796 KB |
Output is correct |
3 |
Correct |
17 ms |
2796 KB |
Output is correct |
4 |
Correct |
17 ms |
2796 KB |
Output is correct |
5 |
Correct |
17 ms |
2796 KB |
Output is correct |
6 |
Correct |
17 ms |
2796 KB |
Output is correct |
7 |
Correct |
17 ms |
2924 KB |
Output is correct |
8 |
Correct |
20 ms |
2924 KB |
Output is correct |
9 |
Correct |
18 ms |
2924 KB |
Output is correct |
10 |
Correct |
17 ms |
2924 KB |
Output is correct |
11 |
Correct |
18 ms |
2924 KB |
Output is correct |
12 |
Correct |
21 ms |
2876 KB |
Output is correct |
13 |
Correct |
19 ms |
2924 KB |
Output is correct |
14 |
Correct |
19 ms |
3052 KB |
Output is correct |
15 |
Correct |
24 ms |
3052 KB |
Output is correct |
16 |
Correct |
28 ms |
3180 KB |
Output is correct |
17 |
Correct |
30 ms |
3180 KB |
Output is correct |
18 |
Correct |
32 ms |
3328 KB |
Output is correct |
19 |
Correct |
33 ms |
3308 KB |
Output is correct |
20 |
Correct |
35 ms |
3436 KB |
Output is correct |