// https://oj.uz/problem/view/JOI15_sterilizing
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<ll> seg;
vector<ll> arr;
int n,q;ll k;
void build(int l,int r,int node){
// cout<<l<<" "<<r<<endl;
if(l==r){seg[node]=arr[l];return;}
int mid=(l+r)>>1;
int L=node<<1;int R=L|1;
build(l,mid,L);build(mid+1,r,R);
seg[node]=seg[L]+seg[R];
}
void fix(int l,int r,int node,int p,ll val){
if(l==r){seg[node]=arr[l]=val;return;}
int mid=(l+r)>>1;
int L=node<<1;int R=L|1;
if(p<=mid)fix(l,mid,L,p,val);
else fix(mid+1,r,R,p,val);
seg[node]=seg[L]+seg[R];
}
void upd(int l,int r,int node,int i,int j){
// cout<<i<<" "<<j<<endl;
if(l==r){
arr[l]/=k;
seg[node]=arr[l];return;
}
int L=node<<1;int R=L|1;
int mid=(l+r)>>1;
if(mid<i){upd(mid+1,r,R,i,j);}
else if(mid>=j){upd(l,mid,L,i,j);}
else {upd(l,mid,L,i,mid);
upd(mid+1,r,R,mid+1,j);}
seg[node]=seg[L]+seg[R];
}
ll query(int l,int r,int node,int i,int j){
if(l==i &&j==r){return seg[node];}
int L=node<<1;int R=L|1;
int mid=(l+r)>>1;
if(mid<i){return query(mid+1,r,R,i,j);}
if(mid>=j){return query(l,mid,R,i,j);}
return query(l,mid,L,i,mid)+query(mid+1,r,R,mid+1,j);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
cin>>n>>q>>k;
arr.resize(n+1);
seg.resize(4*n);
for(int i=1;i<=n;i++)cin>>arr[i];
build(1,n,1);
int t,a;ll b;
// cout<<"test";
// upd(1,n,1,1,3);
// cout<<query(1,n,1,1,n);
for(int i=0;i<q;i++){
cin>>t>>a>>b;
if(t==1){
fix(1,n,1,a,b);
// cout<<"f "<<a<<" "<<b<<query(1,n,1,1,n)<<endl;
}else if(t==2){
upd(1,n,1,a,b);
// cout<<"u "<<a<<" "<<b<<query(1,n,1,1,n)<<endl;
}else {cout<<query(1,n,1,a,b)<<endl;}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4658 ms |
4520 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
247 ms |
968 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2883 ms |
4100 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |