답안 #165314

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
165314 2019-11-26T11:26:15 Z egekabas Relativnost (COCI15_relativnost) C++14
98 / 140
1922 ms 38368 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];

void merge(ll v){
    for(ll i = 0; i <= c; ++i)
        seg[v][i] = 0;
    for(ll i = 0; i <= c; ++i)
        for(ll j = 0; j <= c; ++j){
            seg[v][min(c, i+j)] += seg[2*v][i]*seg[2*v+1][j];
        }
    for(ll i = 0; i <= c; ++i)
        seg[v][i] %= mod;
}
void modify(ll p) {
    seg[p+n][0] = b[p]%mod;
    seg[p+n][1] = a[p]%mod;
    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){
        seg[i+n][0] = b[i]%mod;
        seg[i+n][1] = a[i]%mod;
    }
    for(ll i = n-1; i >= 1; --i)
        merge(i);
    scanf("%lld", &q);
    while(q--){
        ll t1;
        scanf("%lld", &t1);
        --t1;
        scanf("%lld %lld", &a[t1], &b[t1]);
        
        modify(t1);
        printf("%lld\n", seg[1][c]);
    }
}

Compilation message

relativnost.cpp: In function 'int main()':
relativnost.cpp:42: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:45:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &a[i]);
         ~~~~~^~~~~~~~~~~~~~~
relativnost.cpp:47:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &b[i]);
         ~~~~~^~~~~~~~~~~~~~~
relativnost.cpp:54:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld", &q);
     ~~~~~^~~~~~~~~~~~
relativnost.cpp:57:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &t1);
         ~~~~~^~~~~~~~~~~~~
relativnost.cpp:59:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld %lld", &a[t1], &b[t1]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 760 KB Output is correct
2 Correct 10 ms 632 KB Output is correct
3 Correct 15 ms 632 KB Output is correct
4 Correct 369 ms 22008 KB Output is correct
5 Runtime error 1039 ms 35832 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
6 Runtime error 1281 ms 38368 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
7 Correct 661 ms 26396 KB Output is correct
8 Runtime error 420 ms 37368 KB Memory limit exceeded (if you are sure your verdict is not MLE, please contact us)
9 Correct 705 ms 31092 KB Output is correct
10 Correct 1922 ms 29948 KB Output is correct