# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
624233 | MilosMilutinovic | Relativnost (COCI15_relativnost) | C++14 | 4067 ms | 22888 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
* 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];
}
}
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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |