#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 memo2[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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
81 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Runtime error |
79 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
3 |
Runtime error |
64 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
4 |
Runtime error |
79 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
5 |
Runtime error |
70 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
6 |
Runtime error |
64 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
7 |
Runtime error |
113 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
8 |
Runtime error |
82 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
9 |
Runtime error |
80 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
10 |
Runtime error |
91 ms |
66560 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |