SHARE
TWEET

Untitled

a guest Mar 26th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. char mat[1010][1010];
  6. long long dp[1010][1010];
  7. long long mod = 1000000007;
  8.  
  9. int main()
  10. {
  11.     ios_base::sync_with_stdio(false);
  12.     cin.tie(NULL);
  13.    
  14.     int n, m;
  15.     cin >> n >> m;
  16.     for(int i = 0; i < n; i++)
  17.         for(int j = 0; j < m; j++)
  18.             cin >> mat[i][j];
  19.    
  20.     for(int i = 0; i < n; i++) {if(mat[i][0] == '.') dp[i][0] = 1; else break;}
  21.     for(int j = 0; j < m; j++) {if(mat[0][j] == '.') dp[0][j] = 1; else break;}
  22.     for(int i = 1; i < n; i++)
  23.     {
  24.         for(int j = 1; j < m; j++)
  25.         {
  26.             if(mat[i][j] == '.')
  27.                 dp[i][j] = dp[i-1][j] + dp[i][j-1];
  28.             dp[i][j] %= mod;
  29.         }
  30.     }
  31.    
  32.     cout << dp[n-1][m-1];
  33.    
  34.     return 0;
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top