답안 #165294

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
165294 2019-11-26T11:05:39 Z egekabas Relativnost (COCI15_relativnost) C++14
56 / 140
4000 ms 53424 KB
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<ll, ll>  pii;
typedef pair<ld, ld>  pld;
ll n, c, q, mod = 10007;
ll a[100009];
ll b[100009];
ll seg[400009][25];

ll cnt;
void upd(ll v, ll tl, ll tr, ll idx){
    if(idx < tl || idx > tr)
        return;
    if(idx == tl && idx == tr){
        seg[v][0] = b[tl];
        seg[v][1] = a[tl];
    }
    else{
        ll tm = (tl+tr)/2;
        upd(2*v, tl, tm, idx);
        upd(2*v+1, tm+1, tr, idx);
        
        for(ll i = 0; i < c; ++i){
            seg[v][i] = 0;
            for(ll j = 0; j <= i; ++j){
                seg[v][i] += seg[2*v][j]*seg[2*v+1][i-j]%mod;
                seg[v][i] %= mod;
            }
        }
        seg[v][c] = 0;
        for(ll i = 0; i <= c; ++i)
            for(ll j = c-i; j <= c; ++j){
                    seg[v][c] += seg[2*v][i]*seg[2*v+1][j]%mod;
                    seg[v][c] %= mod;
                }
    }
}
void build(ll v, ll tl, ll tr){
    if(tl > tr)
        return;
    if(tl == tr){
        seg[v][0] = b[tl];
        seg[v][1] = a[tl];
    }
    else{
        ll tm = (tl+tr)/2;
        build(2*v, tl, tm);
        build(2*v+1, tm+1, tr);
        for(ll i = 0; i < c; ++i){
            seg[v][i] = 0;
            for(ll j = 0; j <= i; ++j){
                seg[v][i] += seg[2*v][j]*seg[2*v+1][i-j]%mod;
                seg[v][i] %= mod;
            }
        }
        seg[v][c] = 0;
        for(ll i = 0; i <= c; ++i)
            for(ll j = c-i; j <= c; ++j){
                    seg[v][c] += seg[2*v][i]*seg[2*v+1][j]%mod;
                    seg[v][c] %= mod;
                }    }
}
int main() {
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);

    scanf("%lld %lld", &n, &c);
    
    for(ll i = 0; i < n; ++i)
        scanf("%lld", &a[i]);
    for(ll i = 0; i < n; ++i)
        scanf("%lld", &b[i]);
    build(1, 0, n-1);
    scanf("%lld", &q);
    while(q--){
        ll t1, t2, t3;
        scanf("%lld %lld %lld", &t1, &t2, &t3);
        --t1;
        a[t1] = t2;
        b[t1] = t3;
        upd(1, 0, n-1, t1);
        printf("%lld\n", seg[1][c]);
    }
}

Compilation message

relativnost.cpp: In function 'int main()':
relativnost.cpp:77:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld %lld", &n, &c);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~
relativnost.cpp:80:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &a[i]);
         ~~~~~^~~~~~~~~~~~~~~
relativnost.cpp:82:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &b[i]);
         ~~~~~^~~~~~~~~~~~~~~
relativnost.cpp:84:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld", &q);
     ~~~~~^~~~~~~~~~~~
relativnost.cpp:87:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld %lld %lld", &t1, &t2, &t3);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 764 KB Output is correct
2 Correct 65 ms 888 KB Output is correct
3 Correct 133 ms 832 KB Output is correct
4 Correct 2049 ms 27268 KB Output is correct
5 Execution timed out 4019 ms 53420 KB Time limit exceeded
6 Execution timed out 4093 ms 53424 KB Time limit exceeded
7 Execution timed out 4022 ms 27456 KB Time limit exceeded
8 Runtime error 2409 ms 53388 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
9 Execution timed out 4027 ms 53384 KB Time limit exceeded
10 Execution timed out 4009 ms 45932 KB Time limit exceeded