# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
973796 | sleepntsheep | Relativnost (COCI15_relativnost) | C11 | 2673 ms | 17200 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.
#pragma GCC optimize("O3,unroll-loops")
#include <stdio.h>
#define N 100000
#define C 20
const long long MOD = 10007;
int q, n, c, a[N], b[N], p, aa, bb;
int t[N<<1][C+1];
void base(int i)
{
t[i+n][0] = b[i] % MOD;
t[i+n][1] = a[i] % MOD;
}
void pul(int 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)
{
int l = j+k<=c?j+k:c;
t[i][l] = (t[i][l] + t[i<<1][j] * 1ll * t[i<<1|1][k]) % MOD;
}
}
}
int main()
{
scanf("%d%d",&n,&c);
for (int i = 0; i < n; ++i) scanf("%d", a+i);
for (int i = 0; i < n; ++i) scanf("%d", b+i), base(i);
for (int i = n; --i;) pul(i);
scanf("%d", &q);
while (q--)
{
scanf("%d%d%d", &p, &aa, &bb), --p;
a[p] = aa, b[p] = bb;
base(p);
for (p+=n;p>>=1;) pul(p);
printf("%d\n", t[1][c]);
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |