-
Notifications
You must be signed in to change notification settings - Fork 18
/
code(Grid Paths).cpp
50 lines (40 loc) · 951 Bytes
/
code(Grid Paths).cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long int n;
cin>>n;
string s;
long long int mod = 1e9+7;
vector<vector<long long int>> dp(n+1,vector<long long int> (n+1,0));
dp[0][0] = 1;
for(long long int i=0;i<n;i++)
{
cin>>s;
for(long long int j=0;j<n;j++)
{
if(s[j] != '*')
{
if(i>0)
{
dp[i][j] += dp[i-1][j];
dp[i][j] %= mod;
}
if(j>0)
{
dp[i][j] += dp[i][j-1];
dp[i][j] %= mod;
}
}
else
{
dp[i][j] = 0;
}
}
}
cout<< ( n>0 ? (dp[n-1][n-1] % mod) : -1);
return 0;
}