# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
973783 | sleepntsheep | Relativnost (COCI15_relativnost) | C11 | 1179 ms | 19864 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 <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], tt[N<<1];
void base(int i)
{
t[i+n][0] = b[i] % MOD;
t[i+n][1] = a[i] % MOD;
tt[i+n] = (a[i] + 0ll + b[i]) % MOD;
}
void pul(int i)
{
for (int j = 0; j < c; ++j)
{
t[i][j] = 0;
for (int k = 0; k <= j; ++k)
t[i][j] = (t[i][j] + t[i<<1][k] * 1ll * t[i<<1|1][j-k] % MOD) % MOD;
}
tt[i] = tt[i<<1] * 1ll * tt[i<<1|1] % MOD;
}
int main()
{
scanf("%d%d",&n,&c);
for (int i = 0; i < n; ++i) scanf("%d%d", a+i, 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);
int ans = tt[1];
for (int i = 0; i < c; ++i)
ans = (ans + MOD - t[1][i]) % MOD;
printf("%d\n", ans);
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |