线段树求矩形面积和,模板题(数据全部为整数)
#include#include #include using namespace std;#define MAX 10010#define LCH(n) ((n)<<1)#define RCH(n) ((n)<<1|1)struct segment{ int l,r,h,f;}ss[2*MAX];struct node{ int l,r,cnt,len; int mid() { return (l+r)>>1; }}tt[2*MAX*4];int pos[2*MAX];int nums;int cmp(struct segment p ,struct segment q){ return p.h >1; if(key==pos[mid]) return mid; else if(key mid) updata(a,b,val,RCH(rt)); else { updata(a,mid,val,LCH(rt)); updata(mid+1,b,val,RCH(rt)); } cal(rt);}int main(){ int n; while(scanf("%d",&n)!=EOF) { nums=0; for(int i=0; i