-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
34 lines (30 loc) · 727 Bytes
/
Copy pathmain.cpp
File metadata and controls
34 lines (30 loc) · 727 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
#include <bits/stdc++.h>
using namespace std;
constexpr int mod = 1'000'000'007;
constexpr int add(int a, int b) {
return a + b < mod ? a + b : a + b - mod;
}
auto sol = [](int n, int m, auto v) {
vector dp(m, 0);
for (int i = 0; i < m; i++) {
if (v[0][i] == '#') break;
dp[i] = 1;
}
for (int i = 1; i < n; i++) {
vector ndp(m, 0);
for (int j = 0; j < m; j++) {
if (v[i][j] == '#') continue;
ndp[j] = dp[j];
if (j > 0) ndp[j] = add(ndp[j], ndp[j - 1]);
}
dp.swap(ndp);
}
return dp[m - 1];
};
int main() {
cin.tie(0)->sync_with_stdio(0);
int n, m; cin >> n >> m;
vector v(n, string{});
for (int i = 0; i < n; i++) cin >> v[i];
cout << sol(n, m, v) << '\n';
}