#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int N,M, K;
const long long mod = 1e9+7;
long long mat[300][300];
long long memo[300][300][301];
long long memo2[300][300][301];
bool vis[300][300][301];
long long dp(int i, int j, long long s) {
if (i < 0 ||j<0)return 0;
s*=mat[i][j];
if ( s >= K)return 0;
if (vis[i][j][s])
return memo[i][j][s];
if (i==0 && j==0)return 1;
vis[i][j][s]=true;
return memo[i][j][s] = (dp(i-1,j,s)+dp(i,j-1,s))%mod;
}
long long dp2(int i, int j, long long s) {
if (i < 0 ||j<0)return 0;
if (memo2[i][j][s])
return memo2[i][j][s];
if (i==0 || j==0)return 1;
return memo[i][j][s] = (dp2(i-1,j,s)+dp2(i,j-1,s))%mod;
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin >>N>>M>>K;
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
cin >> mat[i][j];
}
}
cout << (dp2(N-1,M-1,1)-dp(N-1,M-1,1)+mod)%mod;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6093 ms |
4500 KB |
Time limit exceeded |
2 |
Execution timed out |
6068 ms |
4516 KB |
Time limit exceeded |
3 |
Execution timed out |
6058 ms |
1856 KB |
Time limit exceeded |
4 |
Execution timed out |
6099 ms |
1884 KB |
Time limit exceeded |
5 |
Execution timed out |
6058 ms |
1988 KB |
Time limit exceeded |
6 |
Execution timed out |
6079 ms |
1912 KB |
Time limit exceeded |
7 |
Execution timed out |
6047 ms |
1784 KB |
Time limit exceeded |
8 |
Execution timed out |
6076 ms |
3320 KB |
Time limit exceeded |
9 |
Execution timed out |
6081 ms |
4572 KB |
Time limit exceeded |
10 |
Execution timed out |
6086 ms |
4600 KB |
Time limit exceeded |