답안 #1005736

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005736 2024-06-23T00:39:22 Z vjudge1 Relativnost (COCI15_relativnost) C++17
140 / 140
2955 ms 17844 KB
#include <bits/stdc++.h>
using namespace std;


const int MAXN=100005;
int n,c;
int a[MAXN], b[MAXN];
int T[2*MAXN][21]; 
const int mod = 10007;

void update(int x){
  for (int i=0; i<=c; i++) T[x][i]=0;
  for (int i=0; i<=c; i++){
    for (int j=0; j<=c; j++){
       (T[x][min(c,i+j)]+=(T[2*x][i]*T[2*x+1][j])%mod)%=mod;
    }
  }
}

void change(int x){
  x+=n;
  //memset(T[x], 0, sizeof T[x]);
  T[x][0]=b[x-n]%mod, T[x][1]=a[x-n]%mod;

  for (x/=2; x>0; x/=2) {
    update(x);
  }
}


signed main(){
  cin>>n>>c;
  for (int i=0; i<n; i++) cin>>a[i];
  for (int i=0; i<n; i++) cin>>b[i];
  for (int i=0; i<n; i++){
    T[i+n][0]=b[i]%mod;
    T[i+n][1]=a[i]%mod;
  }
  for (int i=n-1; i>=1; i--){
    update(i);
  }

  int q; cin>>q;
  while(q--){
    int p; cin>>p;
    p--;
    cin>>a[p]>>b[p];
    change(p);
    cout<<T[1][c]<<'\n';
  }




}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2652 KB Output is correct
2 Correct 13 ms 2636 KB Output is correct
3 Correct 22 ms 2620 KB Output is correct
4 Correct 419 ms 13436 KB Output is correct
5 Correct 1296 ms 17748 KB Output is correct
6 Correct 1816 ms 17844 KB Output is correct
7 Correct 857 ms 13392 KB Output is correct
8 Correct 430 ms 17492 KB Output is correct
9 Correct 813 ms 15696 KB Output is correct
10 Correct 2955 ms 15820 KB Output is correct