參考了胡浩大牛的**風格。
#include#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
const int maxn = 100010;
long long add[maxn*4+1]; long long sum[maxn*4+1];
void pushup(int rt)
void pushdown(int rt,int m)
}void build(int l,int r,int rt)
int m=(l+r)/2;
build(lson);
build(rson);
pushup(rt);
}void update(int l,int r,int c,int l,int r,int rt)
pushdown(rt,r-l+1);
int m=(l+r)/2;
if(l<=m) update(l,r,c,lson);
if(r>m) update(l,r,c,rson);
pushup(rt);
}long long query(int l,int r,int l,int r,int rt)
pushdown(rt,r-l+1);
int m=(l+r)/2;
if(l<=m) ret+=query(l,r,lson);
if(r>m) ret+=query(l,r,rson);
return ret;
}int main()
else if(ch[0]=='c')
}return 0;
}
poj3468之線段樹
include include include include include include include include include define inf 99999999 using namespace std const int max 100000 10 int64 sum max ...
POJ 3468 線段樹區間
這個題目是第二個區間修改的線段樹了,做到現在可以發現線段樹真的非常的靈活,特別是區間修改部分,前面的單點修改其實還是也可參看模版的,區間修改就真的非常靈活了了。這個題目就是區間加法,然後求乙個累加和,同樣地也是需要乙個延遲標誌的,也就是lazy,然後還需要乙個統計當前區間的全部和的陣列。就可以輕鬆解...
poj3468 線段樹成段更新模板
include include include include include using namespace std define lson l,m,rt 1 define rson m 1,r,rt 1 1 define clear a memset a,0,sizeof a const int...