# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1005734 | vjudge1 | Relativnost (COCI15_relativnost) | C++17 | 2591 ms | 35012 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |