OIer_Hhy @ 2024-06-05 19:08:55
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=1e5+20;
int a[maxn],n,q,u,v,x,y,z,opt;
struct SegmentTree{
struct Node{
int l,r,num,tag;
}tree[maxn*4];
inline void push_up(int p){
tree[p].num=tree[p<<1].num+tree[(p<<1)+1].num;
}
inline void build(int p,int l,int r){
tree[p].tag=0;
tree[p].l=l;tree[p].r=r;
if(l==r){
tree[p].num=a[l];
return ;
}
int m=(l+r)>>1;
build(p<<1,l,m);
build((p<<1)+1,m+1,r);
push_up(p);
}
inline void func(int p,int l,int r,int k){
tree[p].tag+=k;
tree[p].num+=k*(r-l+1);
}
inline void push_down(int p,int l,int r){
int m=(l+r)>>1;
func(p<<1,l,m,tree[p].tag);
func((p<<1)+1,m+1,r,tree[p].tag);
tree[p].tag=0;
}
inline void update(int p,int l,int r,int k){
if(x<=l&&r<=y){
tree[p].num+=k*(r-l+1);
tree[p].tag+=k;
return ;
}
push_down(p,l,r);
int m=(l+r)>>1;
if(x<=m)update(p<<1,l,m,k);
if(y>m) update((p<<1)+1,m+1,r,k);
push_up(p);
}
int query(int p,int l,int r){
int res=0;
if(u<=l&&r<=v)return tree[p].num;
int m=(l+r)>>1;
push_down(p,l,r);
if(u<=m)res+=query(p<<1,l,m);
if(v>m) res+=query((p<<1)+1,m+1,r);
return res;
}
}ST;
signed main(){
n=2;
q=1;
for(int i=1;i<=n;i++) cin>>a[i];
ST.build(1,1,n);
while(q--)
cout<<ST.query(1,1,n)<<endl;
return 0;
}
by 鳶一折纸 @ 2024-06-05 19:16:59
@LALaker 你要不要看看你query里写的什么
by 鳶一折纸 @ 2024-06-05 19:18:56
查询0到0是吧
by OIer_Hhy @ 2024-06-05 19:19:48
@鳶一折纸 谢谢,过了,关注了!
by ATION001 @ 2024-06-06 23:21:40
我怀疑是不是我看错题了
by iamsharkbee @ 2024-06-13 18:11:40
???这是a+b???
by thy80 @ 2024-06-15 08:43:58
我一定是看错题了
by lichongkai @ 2024-06-15 21:44:02
有必要写的这么复杂吗?!
by qcx2024 @ 2024-06-18 20:03:11
搁这儿装逼练高精度呢
by hcodm @ 2024-06-22 08:27:56
<<真.a+b>>
by heyuyan @ 2024-06-22 17:15:39
这是a+b?