# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
624228 | MilosMilutinovic | Relativnost (COCI15_relativnost) | C++14 | 4099 ms | 22328 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.
/**
* 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].second;
a[i].first %= 10007;
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;
dp[i][min(p + q, c)] %= 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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |