Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<ctime>
- #include<map>
- #include<vector>
- #include<queue>
- using namespace std;
- int n;
- int dp[1000][1000];
- char square[1000][1000];
- int MOD;
- int rec(int i=0, int j=0){
- if((i==n-1)and(j==n-1)){
- return 1;
- }
- if(dp[i][j]!=-1){
- return dp[i][j];
- }
- int result=0;
- if((square[i+1][j]!='*')and(i+1<n)){
- result+=rec(i+1, j);
- result %= MOD;
- }
- if((square[i][j+1]!='*')and(j+1<n)){
- result+=rec(i, j+1);
- result %= MOD;
- }
- dp[i][j] = result;
- return(result);
- }
- int main()
- {
- MOD = 1e9 + 7;
- cin>>n;
- for(int i=0; i<n; i++){
- for(int j=0; j<n; j++){
- cin>>square[i][j];
- }
- }
- for(int i=0; i<n; i++){
- for(int j=0; j<n; j++){
- dp[i][j]=-1;
- }
- }
- if(square[0][0] == '*') {
- cout << 0 << endl;
- }
- else
- cout<<rec(0, 0)<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement