제출 #1005734

#제출 시각아이디문제언어결과실행 시간메모리
1005734vjudge1Relativnost (COCI15_relativnost)C++17
98 / 140
2591 ms35012 KiB
#include <bits/stdc++.h> using namespace std; #define int long long 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'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...