Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- s = []
- n, m = map(int, input().split())
- for i in range(n+1-1):
- s.append(list(map(int, input().split())))
- z = [0] * n
- for i in range(n+1-1):
- z[i] = [0] * m
- for i in range(n):
- for j in range(m):
- if s[i][j] == 1:
- if i - 1 >= 0 and j - 1 >= 0:
- z[i][j] = z[i][j - 1] + z[i - 1][j]
- elif j - 1 >= 0 and i - 1 < 0:
- z[i][j] = z[i][j - 1]
- elif i - 1 < 0 and j - 1 < 0:
- z[i][j] = 1
- elif j - 1 < 0 and i - 1 >= 0 :
- z[i][j] = z[i - 1][j]
- po=1
- if z[-1][-1] != 0:
- print(z[-1][-1])
- elif z[-1][-1] == 0:
- print("Impossible")
- else:
- print("Impossible")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement