# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
990626 |
2024-05-30T18:16:35 Z |
LOLOLO |
Mobitel (COCI19_mobitel) |
C++17 |
|
2574 ms |
15560 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f first
#define s second
#define pb push_back
#define ep emplace
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define uniquev(v) sort(all(v)), (v).resize(unique(all(v)) - (v).begin())
#define mem(f,x) memset(f , x , sizeof(f))
#define sz(x) (ll)(x).size()
#define __lcm(a, b) (1ll * ((a) / __gcd((a), (b))) * (b))
#define mxx *max_element
#define mnn *min_element
#define cntbit(x) __builtin_popcountll(x)
#define len(x) (int)(x.length())
const int N = 310;
vector <int> val;
ll dp[2][N][2024], cnt[N][N], mod = 1e9 + 7;
int mat[N][N];
int find(int v) {
int p = upper_bound(all(val), v) - val.begin() - 1;
return p;
}
ll solve() {
int r, s, n;
cin >> r >> s >> n;
n--;
for (int i = 1; i <= n; i++)
val.pb(n / i);
uniquev(val);
cnt[1][0] = 1;
for (int i = 1; i <= r; i++) {
for (int j = 1; j <= s; j++) {
cin >> mat[i][j];
cnt[i][j] = (cnt[i][j - 1] + cnt[i - 1][j]) % mod;
}
}
dp[0][1][sz(val) - 1] = 1;
for (int i = 1; i <= r; i++) {
int t = i % 2;
mem(dp[t], 0);
for (int j = 1; j <= s; j++) {
for (int f = 0; f < sz(val); f++) {
int pos = find(val[f] / mat[i][j]);
if (pos < 0)
continue;
dp[t][j][pos] = (dp[t][j][pos] + dp[t][j - 1][f] + dp[1 - t][j][f]) % mod;
}
}
}
ll tot = 0;
for (int i = 0; i < sz(val); i++)
tot = (tot + dp[r % 2][s][i]) % mod;
return (cnt[r][s] - tot);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
//cin >> t;
while (t--) {
cout << solve() << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
42 ms |
11612 KB |
Output isn't correct |
2 |
Correct |
49 ms |
11608 KB |
Output is correct |
3 |
Correct |
317 ms |
14796 KB |
Output is correct |
4 |
Correct |
370 ms |
15396 KB |
Output is correct |
5 |
Correct |
331 ms |
15300 KB |
Output is correct |
6 |
Incorrect |
329 ms |
15312 KB |
Output isn't correct |
7 |
Correct |
158 ms |
14792 KB |
Output is correct |
8 |
Correct |
1465 ms |
15292 KB |
Output is correct |
9 |
Correct |
2556 ms |
15560 KB |
Output is correct |
10 |
Correct |
2574 ms |
15548 KB |
Output is correct |