Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <numeric>
- #include <cmath>
- using namespace std;
- const int N = 1e3, mod = 1e9 + 7;
- char a[N+1][N+1];
- int dp[N+1][N+1], h, w;
- void read()
- {
- cin >> h >> w;
- for (int i = 1; i <= h; ++ i)
- {
- for (int j = 1; j <= w; ++ j)
- {
- cin >> a[i][j];
- }
- }
- }
- void solve()
- {
- dp[0][1] = 1;
- for (int i = 1; i <= h; ++ i)
- {
- for (int j = 1; j <= w; ++ j)
- {
- if (a[i][j] == '#')
- {
- dp[i][j] = 0;
- }
- else
- {
- dp[i][j] = (dp[i][j-1] + dp[i-1][j]) % mod;
- }
- }
- }
- cout << dp[h][w];
- }
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- read();
- solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement