# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
971955 | vjudge1 | Relativnost (COCI15_relativnost) | C++17 | 2649 ms | 30136 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.
//hivongAC=)))
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 10007;
const int mx = 1e5 + 5;
int n, c, q;
int v;
int ap, bp;
int a[mx], b[mx];
struct Node{
int chosen[21];
Node(){
memset(chosen, 0, sizeof(chosen));
}
Node operator + (const Node& lr){
Node res;
for (int i = 0; i <= c; i++) {
for (int j = 0; j <= c; j++) {
res.chosen[min(c, i + j)] = (res.chosen[min(c, i + j)] + chosen[i] * lr.chosen[j]) % maxn;
}
}
return res;
}
} st[3 * mx];
void build(int id, int l, int r){
if(l == r){
st[id].chosen[0] = b[l] % maxn;
st[id].chosen[1] = a[r] % maxn;
return;
}
int m = l + r >> 1;
build(id * 2, l, m);
build(id * 2 + 1, m + 1, r);
st[id] = st[id * 2] + st[id * 2 + 1];
}
void update(int id, int l, int r, int v, int ap, int bp){
if(v < l || r < v) return;
if(l == r){
a[v] = ap;
st[id].chosen[1] = a[v] % maxn;
b[v] = bp;
st[id].chosen[0] = b[v] % maxn;
return;
}
int m = l + r >> 1;
update(id * 2, l, m, v, ap, bp);
update(id * 2 + 1, m + 1, r, v, ap, bp);
st[id] = st[id * 2] + st[id * 2 + 1];
}
int main(){
cin >> n >> c;
for(int i = 1 ; i <= n; i++) cin >> a[i];
for(int i = 1; i <= n; i++) cin >> b[i];
build(1, 1, n);
cin >> q;
while(q--){
cin >> v >> ap >> bp;
update(1, 1, n, v, ap, bp);
cout << st[1].chosen[c] << "\n";
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |