This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3", "inline")
#include <bits/stdc++.h>
using namespace std;
#define ins insert
#define pb push_back
#define int long long int
#define pii pair<int, int>
#define endl '\n'
#define drop(x) cout<<(x)<<endl; return;
#define all(x) x.begin(),x.end()
const int mod = 1e9 +7, sze = 4*100000, inf = 2e18, prime = 23;
int T[sze];
void upd(int node,int idx,int l,int r,int v){
if(l==r){
T[node]=v;
return;
}
int mid = (l+r)/2;
if(idx<=mid){
upd(2*node,idx,l,mid,v);
}
else{
upd(2*node +1,idx,mid+1,r,v);
}
T[node]= T[2*node] + T[2*node +1];
}
void sil(int node,int l,int r,int lx,int rx,int v){
// cout<<T[node]<<endl;
if(lx>r || rx<l || T[node]==0){
return;
}
if(lx==rx){
// cout<<T[node]<<" silirem"<<endl;
T[node]/=v;
return;
}
int mid = (lx+rx)/2;
sil(2*node,l,r,lx,mid,v);
sil(2*node +1,l,r,mid+1,rx,v);
T[node]= T[2*node] + T[2*node +1];
}
int qry(int node,int l,int r,int lx,int rx){
if(l>rx || lx>r){
return 0;
}
if(lx>=l && rx<=r){
return T[node];
}
int mid = (lx+rx)/2;
int left = qry(2*node,l,r,lx,mid);
int right = qry(2*node +1,l,r,mid+1,rx);
return left+right;
}
void mal(){
int n,m,k;
cin>>n>>m>>k;
for(int i=0;i<n;i++){
int x;cin>>x;
upd(1,i,0,n-1,x);
}
while(m--){
int op;cin>>op;
if(op==1){
int idx,v;cin>>idx>>v;
upd(1,--idx,0,n-1,v);
}
else if(op==2){
int l,r;cin>>l>>r;
--l;--r;
sil(1,l,r,0,n-1,k);
// cout<<"sildim: "<<T[1]<<endl;
}
else if(op==3){
int l,r;cin>>l>>r;
--l;--r;
cout<<qry(1,l,r,0,n-1)<<endl;
}
}
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
int tt = 1;
// cin>>tt;
while(tt--){
mal();
}
}
# | 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... |