Submission #624232

#TimeUsernameProblemLanguageResultExecution timeMemory
624232MilosMilutinovicRelativnost (COCI15_relativnost)C++14
126 / 140
4097 ms22656 KiB
/** * author: wxhtzdy * created: 07.08.2022 15:06:04 **/ #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, c; cin >> n >> c; vector<pair<int, int>> a(n); for (int i = 0; i < n; i++) { cin >> a[i].first; a[i].first %= 10007; } for (int i = 0; i < n; i++) { cin >> a[i].second; a[i].second %= 10007; } vector<vector<int>> dp(2 * n + 1, vector<int>(c + 1)); function<void(int)> Update = [&](int i) { i += n; for (int j = 0; j <= c; j++) { dp[i][j] = 0; } dp[i][0] = a[i - n].second; dp[i][1] = a[i - n].first; for (i /= 2; i > 0; i /= 2) { for (int p = 0; p <= c; p++) { dp[i][p] = 0; } for (int p = 0; p <= c; p++) { for (int q = 0; q <= c; q++) { dp[i][min(p + q, c)] += (dp[i * 2][p] * dp[i * 2 + 1][q]) % 10007; } } for (int p = 0; p <= c; p++) { dp[i][p] %= 10007; } } }; for (int i = 0; i < n; i++) { Update(i); } int q; cin >> q; while (q--) { int idx, x, y; cin >> idx >> x >> y; --idx; x %= 10007; y %= 10007; a[idx].first = x; a[idx].second = y; Update(idx); cout << dp[1][c] << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...