Submission #990626

#TimeUsernameProblemLanguageResultExecution timeMemory
990626LOLOLOMobitel (COCI19_mobitel)C++17
104 / 130
2574 ms15560 KiB
#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 timeMemoryGrader output
Fetching results...