fork download
  1. #include <bits/stdc++.h>
  2. #define FOR(start,end,jump) for(int i=start;i<=end;i+=jump)
  3. #define fi first
  4. #define se second
  5. #define ps(any) push_back(any)
  6. using namespace std;
  7.  
  8. const int MOD=1e9+7;
  9. const int maxn=1e3+3;
  10.  
  11. vector<string> a;
  12. int n,m,f[maxn][maxn];
  13. void READ(){
  14. ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  15. cin>>n>>m;
  16. a.resize(n);
  17. FOR(0,n-1,1) cin>>a[i];
  18. }
  19.  
  20. int dp(int i, int j)
  21. {
  22. if(f[i][j]!=-1) return f[i][j];
  23. if(i==n || j==m || a[i][j]=='#') return 0;
  24. if(i==n-1 && j==m-1) return 1;
  25. f[i][j]=(dp(i,j+1)%MOD+dp(i+1,j)%MOD)%MOD;
  26. return f[i][j]%MOD;
  27. }
  28.  
  29. void DO(){
  30. memset(f,-1,sizeof(f));
  31. cout<<dp(0,0);
  32. }
  33.  
  34. int main()
  35. {
  36. READ();
  37. DO();
  38. }
  39.  
Success #stdin #stdout 0.01s 7472KB
stdin
Standard input is empty
stdout
Standard output is empty