Submission #225206

#TimeUsernameProblemLanguageResultExecution timeMemory
225206VimmerMobitel (COCI19_mobitel)C++14
0 / 130
739 ms65540 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(998244353) using namespace std; typedef long long ll; typedef long double ld; vector <pair <int, int> > dp[301][301]; int a[305][305]; int main() { ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, k; cin >> n >> m >> k; if (k > 300) exit(0); for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) cin >> a[i][j]; dp[0][0].pb({1, a[0][0]}); for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) for (auto it : dp[i][j]) { if (it.F == 0) continue; if (i + 1 != n) { int val = it.S * a[i + 1][j]; val = min(val, k); bool f = 0; for (int u = 0; u < sz(dp[i + 1][j]); u++) if (dp[i + 1][j][u].S == val) {f = 1; dp[i + 1][j][u].F = (dp[i + 1][j][u].F + it.F) % MOD; break;} if (!f) dp[i + 1][j].pb({it.F, val}); } if (j + 1 != m) { int val = it.S * a[i][j + 1]; val = min(val, k); bool f = 0; for (int u = 0; u < sz(dp[i][j + 1]); u++) if (dp[i][j + 1][u].S == val) {f = 1; dp[i][j + 1][u].F = (dp[i][j + 1][u].F + it.F) % MOD; break;} if (!f) dp[i][j + 1].pb({it.F, val}); } } int ans = 0; for (auto it : dp[n - 1][m - 1]) if (it.S == k) ans = (ans + it.F) % MOD; cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...