답안 #165295

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
165295 2019-11-26T11:06:34 Z egekabas Relativnost (COCI15_relativnost) C++14
56 / 140
4000 ms 37168 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;
ll merge(ll v){
    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 modify(int p) {
    seg[p+n][0] = b[p];
    seg[p+n][1] = a[p];
    p += n;
    for (; p > 1; p /= 2)
        merge(p/2);
}
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]);
    for(ll i = 0; i < n; ++i)
        modify(i);
    scanf("%lld", &q);
    while(q--){
        ll t1, t2, t3;
        scanf("%lld %lld %lld", &t1, &t2, &t3);
        --t1;
        a[t1] = t2;
        b[t1] = t3;
        modify(t1);
        printf("%lld\n", seg[1][c]);
    }
}

Compilation message

relativnost.cpp: In function 'll merge(ll)':
relativnost.cpp:34:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
relativnost.cpp: In function 'int main()':
relativnost.cpp:47: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:50:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &a[i]);
         ~~~~~^~~~~~~~~~~~~~~
relativnost.cpp:52:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &b[i]);
         ~~~~~^~~~~~~~~~~~~~~
relativnost.cpp:55:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld", &q);
     ~~~~~^~~~~~~~~~~~
relativnost.cpp:58: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 58 ms 888 KB Output is correct
2 Correct 90 ms 764 KB Output is correct
3 Correct 191 ms 792 KB Output is correct
4 Correct 3418 ms 22156 KB Output is correct
5 Execution timed out 4009 ms 20964 KB Time limit exceeded
6 Execution timed out 4043 ms 12268 KB Time limit exceeded
7 Execution timed out 4013 ms 23824 KB Time limit exceeded
8 Execution timed out 4021 ms 37168 KB Time limit exceeded
9 Execution timed out 4038 ms 30752 KB Time limit exceeded
10 Execution timed out 4019 ms 10240 KB Time limit exceeded