# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
225048 | Vimmer | Mobitel (COCI19_mobitel) | C++14 | 6084 ms | 1792 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 <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 100005
#define MOD ll(1e9 + 7)
using namespace std;
typedef long long ll;
typedef long double ld;
ll a[305][305], dp[305][305], n, m, s, ans;
void rec(int x, int y, ll sm)
{
if (sm >= s) {ans = (ans + dp[x][y]) % MOD; return;}
if (x + 1 != n) rec(x + 1, y, sm * a[x + 1][y]);
if (y + 1 != m) rec(x, y + 1, sm * a[x][y + 1]);
}
int main()
{
ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> m >> s;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++) cin >> a[i][j];
dp[n - 1][m - 1] = 1;
for (int i = n - 1; i >= 0; i--)
for (int j = m - 1; j >= 0; j--)
{
if (i + 1 != n) dp[i][j] += dp[i + 1][j];
if (j + 1 != m) dp[i][j] += dp[i][j + 1];
dp[i][j] %= MOD;
}
rec(0, 0, a[0][0]);
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |