# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
27856 | szawinis | Relativnost (COCI15_relativnost) | C++14 | 3703 ms | 19988 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.
#include <bits/stdc++.h>
using namespace std;
const int MAX = (1e5)+5, MOD = (1e4)+7;
int n, c, q, a[MAX], b[MAX], t[2*MAX][22];
void update(int x) {
for(int i = (n+x >> 1); i >= 1; i >>= 1) {
for(int j = 0; j <= c; ++j) t[i][j] = 0;
for(int j = 0; j <= c; ++j) for(int k = 0; k <= c; ++k) {
t[i][min(j+k, c)] = (t[i][min(j+k, c)] + t[i<<1][j]*t[i<<1|1][k])%MOD;
}
}
}
int main() {
scanf("%d%d",&n,&c);
for(int i = 0; i < n; ++i) scanf("%d",&t[n+i][1]), t[n+i][1] %= MOD;
for(int i = 0; i < n; ++i) scanf("%d",&t[n+i][0]), t[n+i][0] %= MOD;
for(int i = n-1; i >= 1; --i) {
for(int j = 0; j <= c; ++j) t[i][j] = 0;
for(int j = 0; j <= c; ++j) for(int k = 0; k <= c; ++k) {
t[i][min(j+k, c)] = (t[i][min(j+k, c)] + t[i<<1][j]*t[i<<1|1][k])%MOD;
}
}
scanf("%d",&q);
for(int i, na, nb; q--; ) {
scanf("%d%d%d",&i,&na,&nb); --i;
memset(t[n+i], 0, sizeof(t[n+i]));
t[n+i][1] = na%MOD, t[n+i][0] = nb%MOD;
update(i);
printf("%d\n", t[1][c]);
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |