Submission #225217

#TimeUsernameProblemLanguageResultExecution timeMemory
225217VimmerMobitel (COCI19_mobitel)C++14
26 / 130
308 ms2536 KiB
#include <bits/stdc++.h> //#pragma GCC optimize("unroll-loops") //#pragma GCC optimize("-O3") //#pragma GCC optimize("Ofast") //#pragma GCC optimize("fast-math") //#pragma GCC optimize("no-stack-protector") #define F first #define S second #define sz(x) int(x.size()) #define pb push_back #define N 200005 #define MOD ll(1e9 + 7) using namespace std; typedef long long ll; ll dp[2][301][301], a[301][301]; int main() { ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n, m, k; cin >> n >> m >> k; if (k > 300) exit(0); for (ll i = 0; i < n; i++) for (ll j = 0; j < m; j++) cin >> a[i][j]; dp[0][0][min(k, a[0][0])] = 1; for (ll i = 0; i < n; i++) { for (ll j = 0; j < m; j++) for (ll u = 0; u <= k; u++) { if (i + 1 != n) dp[1][j][min(k, u * a[i + 1][j])] = (dp[1][j][min(k, u * a[i + 1][j])] + dp[0][j][u]) % MOD; if (j + 1 != m) dp[0][j + 1][min(k, u * a[i][j + 1])] = (dp[0][j + 1][min(k, u * a[i][j + 1])] + dp[0][j][u]) % MOD; } if (i + 1 != n) { for (ll j = 0; j < m; j++) for (ll u = 0; u <= k; u++) {dp[0][j][u] = dp[1][j][u]; dp[1][j][u] = 0;} } } cout << dp[0][m - 1][k]; }
#Verdict Execution timeMemoryGrader output
Fetching results...