# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1120118 | Yang8on | Mobitel (COCI19_mobitel) | C++17 | 1716 ms | 6000 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>
#define Y8o "Mobitel"
#define maxn (int) 305
#define ll long long
#define pii pair<int, int>
#define gb(i, j) ((i >> j) & 1)
#define all(x) x.begin(), x.end()
#define _left id * 2, l, mid
#define _right id * 2 + 1, mid + 1, r
#define fi(i, a, b) for(int i = a; i <= b; i ++)
#define fid(i, a, b) for(int i = a; i >= b; i --)
//#define f first
//#define s second
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll GetRandom(ll l, ll r) {
return uniform_int_distribution<ll> (l, r) (rng);
}
void iof() {
ios_base::sync_with_stdio(0);
cin.tie(NULL), cout.tie(NULL);
if(fopen(Y8o".inp", "r"))
{
freopen(Y8o".inp", "r", stdin);
// freopen(Y8o".out", "w", stdout);
}
}
void ctime() {
cerr << "\n" << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
}
const int mod = 1e9 + 7;
void Add(int &x, int y) {
x += y;
if(x >= mod) x -= mod;
if(x < 0) x += mod;
}
int m, n, k;
int a[maxn][maxn], vir[(int)1e6 + 5];
int dp[2][maxn][2005];
vector<int> val;
int need(int x, int y) {
return (x - 1) / y + 1;
}
void solve() {
cin >> m >> n >> k;
fi(i, 1, m) fi(j, 1, n) cin >> a[i][j];
fi(x, 1, k) {
int tmp = need(k, x);
if(val.empty() || val.back() != tmp) {
vir[tmp] = val.size();
val.push_back(tmp);
}
}
dp[0][1][vir[k]] = 1;
fi(i, 1, m) {
fi(j, 1, n) {
for(int pre : val) {
int tmp = vir[need(pre, a[i][j])];
Add(dp[1][j][tmp], dp[0][j][vir[pre]]);
Add(dp[1][j][tmp], dp[1][j - 1][vir[pre]]);
}
}
fi(j, 1, n) {
for(int pre : val) {
dp[0][j][vir[pre]] = dp[1][j][vir[pre]], dp[1][j][vir[pre]] = 0;
}
}
}
cout << dp[0][n][vir[1]];
// dp[0][1][vir[k]] = 1;
// fi(i, 1, m) {
// fi(j, 1, n) {
// for(int pre : val) {
// int tmp = vir[need(pre, a[i][j])];
// Add(dp[i][j][tmp], dp[i - 1][j][vir[pre]]);
// Add(dp[i][j][tmp], dp[i][j - 1][vir[pre]]);
// }
// }
// }
// cout << dp[m][n][vir[1]];
}
int main() {
iof();
int nTest = 1;
// cin >> nTest;
while(nTest --) {
solve();
}
ctime();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |