-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathGrid-1.cpp
72 lines (61 loc) · 1.44 KB
/
Grid-1.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
///////// ///// //// ////
// // // // // // //
////// // // // // //
// // /// // // //
//////// // // // //
*/
#include<bits/stdc++.h>
#include<assert.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
#define Fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fo(i,s,n) for(int i=s;i<n;i++)
#define pb(x) push_back(x);
#define mod 1000000007
int main()
{
Fast
ll h,w;
cin>>h>>w;
ll dp[h][w]={0};
char a;
fo(i,0,w)
dp[0][i]=1;
fo(i,0,h)
dp[i][0]=1;
fo(i,0,h)
{
fo(j,0,w)
{
cin>>a;
if(a=='#')
dp[i][j]=-1;
}
}
if(dp[0][0]==-1)
{
cout<<0;
exit(0);
}
else
{
fo(i,1,h)
{
fo(j,1,w)
{
if(dp[i][j]>=0)
{
if((dp[i][j-1]>=0))
dp[i][j]=dp[i][j]+(dp[i][j-1]);
if(dp[i-1][j]>=0)
dp[i][j]=dp[i][j]+(dp[i-1][j]);
dp[i][j]=(dp[i][j])%mod;
}
}
}
cout<<dp[h-1][w-1]%mod<<endl;
}
return 0;
}