fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main() {
  6.  
  7. int n;
  8. cin>>n;
  9.  
  10. vector<string> V;
  11.  
  12. for(int i=0;i<n;i++)
  13. {
  14. string s;
  15. cin>>s;
  16. V.push_back(s);
  17. }
  18.  
  19. int dp[n][n];
  20. for(int i=0;i<n;i++)
  21. {
  22. for(int j=0;j<n;j++)
  23. {
  24. dp[i][j]=0;
  25. }
  26. }
  27.  
  28. for(int i=0;i<n;i++)
  29. {
  30. if(V[i][0] == '*')
  31. {
  32. break;
  33. }
  34. dp[i][0]=1;
  35. }
  36.  
  37. for(int i=0;i<n;i++)
  38. {
  39. if(V[0][i] == '*')
  40. {
  41. break;
  42. }
  43. dp[0][i]=1;
  44. }
  45.  
  46. int mod =1e9+7;
  47. for(int i=1;i<n;i++)
  48. {
  49. for(int j=1;j<n;j++)
  50. {
  51. if(V[i][j] == '*')
  52. {
  53. continue;
  54. }
  55. dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
  56. }
  57. }
  58.  
  59. cout<<dp[n-1][n-1]<<endl;
  60.  
  61. return 0;
  62. }
Success #stdin #stdout 0.01s 5284KB
stdin
4
....
.*..
...*
*...
stdout
3