Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int dp[1005][1005];
- int n,m;
- int main(){
- scanf("%d%d",&n,&m);
- for(int i=1;i<=n;i++){
- for(int j=1;j<=m;j++){
- scanf("%d",&dp[i][j]);
- if(dp[i][j]) dp[i][j] = -1;
- }
- }
- for(int i=1;i<=n;i++){
- for(int j=1;j<=m;j++){
- if(dp[i][j]==-1)
- continue;
- if(i==1 and j==1)
- dp[i][j] = 1;
- else{
- if(dp[i][j-1]!=-1)
- dp[i][j] += dp[i][j-1];
- if(dp[i-1][j]!=-1)
- dp[i][j] += dp[i-1][j];
- dp[i][j] %= 1000000007;
- }
- }
- }
- printf("%d",dp[n][m]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement