-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathh.cpp
More file actions
42 lines (33 loc) · 697 Bytes
/
Copy pathh.cpp
File metadata and controls
42 lines (33 loc) · 697 Bytes
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
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 1e9 + 7;
ll int INF = 1e17;
ll int dp[1005][1005];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
memset(dp, -1, sizeof dp);
int n, m;
cin>>n>>m;
char c;
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
{
cin>>c;
dp[i][j] = (c == '.') ? 0 : -1;
}
dp[0][0] += 1;
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
if(dp[i][j] > 0)
{
if(dp[i][j+1] != -1)
dp[i][j+1] = (dp[i][j+1] + dp[i][j]) % mod;
if(dp[i+1][j] != -1)
dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % mod;
}
cout<<dp[n-1][m-1]<<endl;
return 0;
}