Submission #973825

# Submission time Handle Problem Language Result Execution time Memory
973825 2024-05-02T11:30:47 Z sleepntsheep Relativnost (COCI15_relativnost) C
140 / 140
1232 ms 17060 KB
#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", 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);
 
        int ans = tt[1];
        for (int i = 0; i < c; ++i)
            ans = (ans + MOD - t[1][i]) % MOD;
        printf("%d\n", ans);
    }
}
 

Compilation message

relativnost.c: In function 'main':
relativnost.c:31:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     scanf("%d%d",&n,&c);
      |     ^~~~~~~~~~~~~~~~~~~
relativnost.c:33:33: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     for (int i = 0; i < n; ++i) scanf("%d", a+i);
      |                                 ^~~~~~~~~~~~~~~~
relativnost.c:34:33: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |     for (int i = 0; i < n; ++i) scanf("%d", b+i), base(i);
      |                                 ^~~~~~~~~~~~~~~~
relativnost.c:38:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |     scanf("%d", &q);
      |     ^~~~~~~~~~~~~~~
relativnost.c:41:9: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |         scanf("%d%d%d", &p, &aa, &bb), --p;
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 604 KB Output is correct
2 Correct 5 ms 348 KB Output is correct
3 Correct 9 ms 348 KB Output is correct
4 Correct 144 ms 9860 KB Output is correct
5 Correct 487 ms 16976 KB Output is correct
6 Correct 751 ms 16860 KB Output is correct
7 Correct 304 ms 12116 KB Output is correct
8 Correct 185 ms 17060 KB Output is correct
9 Correct 295 ms 14672 KB Output is correct
10 Correct 1232 ms 14552 KB Output is correct