fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. const long long MaxN = 1e3+ 5,MOD=1e9+7;
  4. long long n,dp[MaxN][MaxN];
  5. char a[MaxN][MaxN];
  6. void add(long long &a, long long b)
  7. {
  8. a+=b;
  9. if(a>=MOD) a-=MOD;
  10. }
  11. void input()
  12. {
  13. cin >> n;
  14. for (long long i=1; i<=n; i++)
  15. {
  16. for (long long j=1; j<=n; j++)
  17. {
  18. cin >> a[i][j];
  19. }
  20. }
  21. }
  22. void solve()
  23. {
  24. if(a[1][1]=='*')
  25. {
  26. cout << 0;
  27. return ;
  28. }
  29. for (long long i=1; i<=n; i++)
  30. {
  31. for (long long j=1; j<=n; j++)
  32. {
  33. dp[i][j]=0;
  34. }
  35. }
  36. dp[1][1]=1;
  37. for (long long i=1; i<=n; i++)
  38. {
  39. for (long long j=1; j<=n; j++)
  40. {
  41. if(i==1&&j==1) continue;
  42. if(a[i][j]=='.')
  43. {
  44. add(dp[i][j],dp[i-1][j]);
  45. add(dp[i][j],dp[i][j-1]);
  46. }
  47. }
  48. }
  49. cout << dp[n][n];
  50. }
  51. int main()
  52. {
  53. ios_base::sync_with_stdio(0);
  54. cin.tie(0);
  55. input();
  56. solve();
  57. }
  58.  
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout
Standard output is empty