Created
November 19, 2018 09:30
-
-
Save Semior001/ae422ed4c6516b32c7672b5705bba94e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int main(){ | |
int n,m; | |
cin >> n >> m; | |
int a[n+1][m+1]; | |
for(int i = 1; i <= n; i++){ | |
for(int j = 1; j <= m; j++){ | |
cin >> a[i][j]; | |
} | |
} | |
int b[100][100] = {0}; | |
b[1][1] = 1; | |
for(int i = 1; i <= n; i++){ | |
for(int j = 1; j <= m; j++){ | |
for(int i1 = i-1; i1 >= 1; i1--){ | |
if(a[i1][j]==i-i1){ | |
b[i][j]+=b[i1][j]; | |
} | |
} | |
for(int j1 = j-1; j1 >= 1; j1--){ | |
if(a[i][j1]==j-j1){ | |
b[i][j]+=b[i][j1]; | |
} | |
} | |
} | |
} | |
// for(int i = 1; i <= n; i++){ | |
// for(int j = 1; j <= m; j++){ | |
// cout << b[i][j] << " "; | |
// } | |
// cout << endl; | |
// } | |
cout << b[n][m] << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment