Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- int n,m;
- bool matrica[1010][1010];
- ll dp[1010][1010];
- ll modulo=1000000007;
- using namespace std;
- int main()
- {
- ios::sync_with_stdio(false);
- cin.tie(0);
- cin>>n>>m;
- string s;
- for(int i=0;i<n;i++)
- {
- cin>>s;
- for(int j=0;j<m;j++)
- if(s[j]=='.')
- matrica[i][j]=true;
- }
- bool ok=true;
- for(int i=0;i<n;i++)
- if(ok && matrica[i][0])
- dp[i][0]=1;
- else
- ok=false;
- ok=true;
- for(int j=0;j<m;j++)
- if(ok && matrica[0][j])
- dp[0][j]=1;
- else
- ok=false;
- for(int i=1;i<n;i++)
- for(int j=1;j<m;j++)
- if(matrica[i][j])
- dp[i][j]=(dp[i-1][j]+dp[i][j-1])%modulo;
- cout<<dp[n-1][m-1];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement