# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
164340 | beso123 | Relativnost (COCI15_relativnost) | C++14 | 2340 ms | 23168 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>
#define mod 10007
using namespace std;
int n,m,Q,a[100010],b[100010],t[400100][21],sum;
void update(int v){
for(int k=0;k<=m;k++)
t[v][k]=0;
for(int i=0;i<=m;++i)
for(int j=0;j<=m;++j)
t[v][min(i+j,m)]+=(t[v*2][i]*(t[v*2+1][j]))%mod;
for(int k=0;k<=m;k++)
t[v][k]%=mod;
}
void Build(int v,int i,int j){
if(i==j){
t[v][0]=b[i];
t[v][1]=a[i];
return;
}
int mid=(i+j)/2;
Build(v*2,i,mid);
Build(v*2+1,mid+1,j);
update(v);
}
void UPD(int v,int i,int j,int pos){
if(i==j){
t[v][0]=b[i];
t[v][1]=a[i];
return;
}
int mid=(i+j)/2;
if(pos<=mid){
UPD(v*2,i,mid,pos);
}
else{
UPD(v*2+1,mid+1,j,pos);
}
update(v);
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>m;
for(int k=1;k<=n;k++){
cin>>a[k];
a[k]%=mod;
}
for(int k=1;k<=n;k++){
cin>>b[k];
b[k]%=mod;
}
Build(1,1,n);
cin>>Q;
while(Q--){
int x,na,nb;
cin>>x>>na>>nb;
a[x]=na%mod;
b[x]=nb%mod;
UPD(1,1,n,x);
cout<<t[1][m]<<'\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |