Advertisement
Josif_tepe

Untitled

Nov 15th, 2021
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. #include <iostream>
  2. #include<ctime>
  3. #include<map>
  4. #include<vector>
  5. #include<queue>
  6. using namespace std;
  7. int n;
  8. int dp[1000][1000];
  9. char square[1000][1000];
  10. int main()
  11. {
  12.     cin>>n;
  13.  
  14. for(int i=0; i<n; i++){
  15.     for(int j=0; j<n; j++){
  16.         cin>>square[i][j];
  17.     }
  18. }
  19. for(int i=0; i<n; i++){
  20.     for(int j=0; j<n; j++){
  21.         dp[i][j]=0;
  22.     }
  23. }
  24.     if(square[0][0] != '*') {
  25.         dp[0][0] = 1;
  26.     }
  27.     int MOD = 1e9 + 7;
  28.     for(int i = 0; i < n; i++) {
  29.         for(int j = 0; j < n; j++) {
  30.             if(i + 1 < n and square[i + 1][j] != '*') {
  31.                 dp[i + 1][j] += dp[i][j];
  32.                 dp[i + 1][j] %= MOD;
  33.             }
  34.             if(j + 1 < n and square[i][j + 1] != '*') {
  35.                 dp[i][j + 1] += dp[i][j];
  36.                 dp[i][j + 1] %= MOD;
  37.             }
  38.         }
  39.     }
  40.     cout << dp[n - 1][n - 1] << endl;
  41.     return 0;
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement