답안 #1012524

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1012524 2024-07-02T09:26:13 Z Irate Relativnost (COCI15_relativnost) C++17
140 / 140
2012 ms 16724 KB
#include<cstdio>
#include<stack>
using namespace std;
const int MOD = 10007;
const int MAX = 1e5 + 5;
int c;
int sTree[21][MAX << 2];

/// Erdem Kiraz
int add(int x, int y) {
    return x + y >= MOD ? x + y - MOD : x + y;
}

int mul(int x, int y) {
    return x * y % MOD;
}


void Build(int node, int l, int r, pair<int, int> v[]){
    if(l == r){
        sTree[1][node] = v[l].first % MOD;
        sTree[0][node] = v[l].second % MOD;
    }
    else{
        int mid = (l + r) >> 1;
        Build(node << 1, l, mid, v);
        Build(node << 1 | 1, mid + 1, r, v);
        for(int i = 0;i <= c;++i){
            sTree[i][node] = 0;
        }
        for(int i = 0;i <= c;++i){
            for(int j = 0;j <= c;++j){
                sTree[min(i + j, c)][node] = add(sTree[min(i + j, c)][node], mul(sTree[i][node << 1], sTree[j][node << 1 | 1]));
            }
        }
    }
}
void Update(int node, int l, int r, int pos, pair<int, int>&val){
    if(l == r){
        sTree[1][node] = val.first % MOD;
        sTree[0][node] = val.second % MOD;
    }
    else{
        int mid = (l + r) >> 1;
        if(pos <= mid){
            Update(node << 1, l, mid, pos, val);
        }
        else{
            Update(node << 1 | 1, mid + 1, r, pos, val);
        }
        for(int i = 0;i <= c;++i){
            sTree[i][node] = 0;
        }
        for(int i = 0;i <= c;++i){
            for(int j = 0;j <= c;++j){
                sTree[min(i + j, c)][node] = add(sTree[min(i + j, c)][node], mul(sTree[i][node << 1], sTree[j][node << 1 | 1]));
            }
        }
    }
}
int main(){
    // ios_base::sync_with_stdio(0);
    // cin.tie(0);
    int n;
    // cin >> n >> c;
    scanf("%d %d", &n, &c);
    pair<int, int> v[n + 1];
    for(int i = 1;i <= n;++i){
        // cin >> v[i].first;
        scanf("%d", &v[i].first);
    }
    for(int i = 1;i <= n;++i){
        // cin >> v[i].second;
        scanf("%d", &v[i].second);
    }
    Build(1, 1, n, v);

    int q;
    // cin >> q;
    scanf("%d", &q);
    while(q--){
        int indx, f, s;
        // cin >> indx >> f >> s;
        scanf("%d %d %d", &indx, &f, &s);
        pair<int, int>p = {f, s};
        Update(1, 1, n, indx, p);
        int res = sTree[c][1];
        // cout << res << '\n';
        printf("%d\n", res);
    }
}

Compilation message

relativnost.cpp: In function 'int main()':
relativnost.cpp:66:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |     scanf("%d %d", &n, &c);
      |     ~~~~~^~~~~~~~~~~~~~~~~
relativnost.cpp:70:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   70 |         scanf("%d", &v[i].first);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
relativnost.cpp:74:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   74 |         scanf("%d", &v[i].second);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~
relativnost.cpp:80:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   80 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
relativnost.cpp:84:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   84 |         scanf("%d %d %d", &indx, &f, &s);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 6488 KB Output is correct
2 Correct 7 ms 6492 KB Output is correct
3 Correct 16 ms 6764 KB Output is correct
4 Correct 239 ms 8532 KB Output is correct
5 Correct 811 ms 13232 KB Output is correct
6 Correct 1223 ms 15700 KB Output is correct
7 Correct 547 ms 10088 KB Output is correct
8 Correct 273 ms 10324 KB Output is correct
9 Correct 484 ms 11028 KB Output is correct
10 Correct 2012 ms 16724 KB Output is correct