# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
103603 | kishtarn555 | Mobitel (COCI19_mobitel) | C++14 | 101 ms | 66560 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
if (K>300)return 0;
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 |
---|---|---|---|---|
Fetching results... |