-
Notifications
You must be signed in to change notification settings - Fork 0
/
H.cpp
62 lines (57 loc) · 1.55 KB
/
H.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
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<array<int,2>> vii;
typedef vector<int> vi;
#define INF 1000000000
#define MOD 1000000007
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
// http://xorshift.di.unimi.it/splitmix64.c
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
};
int dp[1002][1002];
bool tr[1002][1002];
void solve() {
int n, m;
cin >> n >> m;
for (int i = 1; i <=n; ++i) {
for (int j = 1; j <= m; ++ j) {
char c;
cin >> c;
if (c == '#') tr[i][j] = 1;
}
}
if (!tr[1][1])
dp[1][1] = 1;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
if (i == 1 && j == 1) continue;
if (!tr[i][j]) {
dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
dp[i][j] %= MOD;
}
}
}
cout << dp[n][m] << "\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
int t = 1;
//cin >> t;
while (t--)
solve();
return 0;
}