제출 #1369966

#제출 시각아이디문제언어결과실행 시간메모리
1369966eyadoozRelativnost (COCI15_relativnost)C++20
42 / 140
3873 ms22896 KiB
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
#define endl '\n'
#define mod 10007
// #define int long long
// #define int short
const int N=(1ll<<17);
vector<int> tree[4*N];
vector<int> merg(vector<int> a, vector<int> b) {
    if(a.empty()) a.resize(22, 0), a[0]=1;
    if(b.empty()) b.resize(22, 0), b[0]=1;
    vector<int> ans;
    ans.resize(22, 0);
    // ans[0]=1;
    for(int i = 0;i <= 21;i++) {
        for(int j=0;j<= 21;j++) {
            ans[min(21, i+j)]+=(a[i]*b[j])%mod;
            ans[min(21, i+j)]%=mod;
        }
    }
    return ans;
}
void update(int x, int y, int j) {
    x+=N;
    tree[x].resize(22, 0);
    tree[x][0]=j, tree[x][1]=y;
    while(x>1) {
        x/=2;
        tree[x]=merg(tree[2*x], tree[2*x+1]);
    }
}
// vector<int> query(int l, int r, int ql, int qr, int v) {
//     if(ql<=l&&r<=qr) return tree[v];
//     if(r<ql||l>qr) return {};
//     int mid=(l+r)/2;
//     return merg(query(l, mid, ql, qr, 2*v), query(mid+1, r, ql, qr, 2*v+1));
// }
main()
{
    cin.tie(0) -> sync_with_stdio(0);

    int n, c;
    cin >> n >> c;
    int a[n+1]={}, b[n+1]={};
    for(int i=1;i <= n;i++) cin >> a[i];
    for(int i=1;i <= n;i++) cin >> b[i];
    for(int i = 1;i <= n;i++) update(i, a[i]%mod, b[i]%mod);
    int q;
    cin >> q;
    while(q--) {
        int p;
        cin >> p;
        int x, y;
        cin >> x >> y;
        a[p]=x, b[p]=y;
        update(p, x, y);
        // vector<int> s=query(0, N-1, 1, n, 1);
        vector<int> s=tree[1];
        int ans=0;
        for(int i=c;i<=21;i++) ans+=s[i]%mod, ans%=mod;
        cout << ans << endl;
    }
}
    

컴파일 시 표준 에러 (stderr) 메시지

relativnost.cpp:46:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   46 | main()
      | ^~~~
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…