Submission #697273

#TimeUsernameProblemLanguageResultExecution timeMemory
697273kussssoRelativnost (COCI15_relativnost)C++17
0 / 140
4086 ms13892 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; const int N = 1e5 + 5; const int mod = 10007; int n, c; int q; int a[N]; int b[N]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> c; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) cin >> b[i]; cin >> q; while (q--) { int i, na, nb; cin >> i >> na >> nb; a[i] = na; b[i] = nb; vector<vi> dp(n + 2, vi (c + 2, 0)); dp[0][0] = 1; ll total = 1; ll except = 0; for (int j = 1; j <= n; j++) { total = total * (a[j] + b[j]) % mod; for (int k = 0; k < c; k++) { dp[j][k] += dp[j - 1][k] * b[j]; if (k > 0) dp[j][k] += dp[j - 1][k - 1] * a[j]; dp[j][k] %= mod; if (j == n) { except = (except + dp[j][k]) % mod; } } } cout << total - except << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...