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 N=1<<(int)(ceil(log2(200001)));
int t[N*2+5]={};
struct st{
/*void update(int l,int r,int ql,int qr,int i,int v){
if(l>qr||r<ql)return;
if(l>=ql&&r<=qr){
t[i]/=v;
return;
}
int m=(r+l)/2;
update(l,m,ql,qr,i*2,v);
update(m+1,r,ql,qr,i*2+1,v);
}*/
void update1(int i,int v){
i+=N;
t[i]=v;
while(i>0){
i/=2;
t[i]=t[i*2]+t[i*2+1];
}
}
int query(int l,int r,int ql,int qr,int i){
if(l>qr||r<ql)return 0;
if(l>=ql&&r<=qr)return t[i];
int m=(r+l)/2;
return query(l,m,ql,qr,i*2)+query(m+1,r,ql,qr,i*2+1);
}
int _query(int l,int r){
return query(0,N-1,l,r,1);
}
/*void _update(int l,int r,int v){
update(0,N-1,l,r,1,v);
}*/
};
signed main(){
cin.tie(0)->sync_with_stdio(0);
cout.tie(0)->sync_with_stdio(0);
int n,q,k;
cin>>n>>q>>k;
int a[n];
st sg;
for(int i=0;i<n;i++){
cin>>a[i];
sg.update1(i,a[i]);
}
while(q--){
int tybe;
cin>>tybe;
if(tybe==1){
int a,b;
cin>>a>>b;
a--;
sg.update1(a,b);
}
else if(tybe==2){
int l,r;
cin>>l>>r;
l--;r--;
for(int i=l;i<=r;i++){
sg.update1(i,t[i+N]/k);
}
}
else{
int l,r;
cin>>l>>r;
l--;r--;
cout<<sg._query(l,r)<<'\n';
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |