fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define nmax 1003
  5. const ll mod = 1e9 + 7;
  6. char a[nmax][nmax];
  7. ll dp[nmax][nmax];
  8. ll n ,m;
  9. int go(int x , int y){
  10. if (y > m or x > n or a[x][y] == '#'){
  11. return 0;
  12. }
  13. if (x == n and y == m){
  14. return 1;
  15. }
  16. if (dp[x][y] != -1){
  17. return dp[x][y];
  18. }
  19. return dp[x][y] = (go(x + 1 , y) + go(x , y + 1)) % mod;
  20. }
  21. void solve(){
  22. memset(dp, -1 , sizeof(dp));
  23. cin >> n >> m;
  24. for (int i = 1 ; i <= n ; i++){
  25. for (int j = 1 ; j <= m ; j++){
  26. cin >> a[i][j];
  27. }
  28. }
  29. cout << go(1 , 1);
  30. }
  31. int main(){
  32. solve();
  33. }
  34.  
Success #stdin #stdout 0.01s 11324KB
stdin
Standard input is empty
stdout
Standard output is empty