예제 #1
0
파일: 1174.cpp 프로젝트: 8cbx/code-area
void build(int l,int r,int rt)
{
    if(l==r)
    {
        scanf("%d",&sum[rt]);
        return;
    }
    int m=(l+r)>>1;
    build(lson);
    build(rson);
    Pushup(rt);
}
예제 #2
0
파일: 1546.c 프로젝트: bitchbitch/ACM-ICPC
void fan(int c, int p , int v){
	if(p <= tree[c].l && v >= tree[c].r)  {
		fxor(c);
		return ;
	}
	Pushdown(c);
	if(v <= tree[c].m ) fan(L(c),p,v);
	else if(p > tree[c].m) fan(R(c),p,v);
	else {
		fan(L(c),p,tree[c].m);
		fan(R(c),tree[c].m+1,v);
	}
	Pushup(c);

}
예제 #3
0
파일: 1546.c 프로젝트: bitchbitch/ACM-ICPC
void update(int c , int p , int  v, int value){
	if(p <= tree[c].l  && v >= tree[c].r) {
		tree[c].c = value;
		tree[c].f = 0 ;
		tree[c].sum  = tree[c].c * (tree[c].r - tree[c].l +1);
		return ;
	}
	Pushdown(c);
	if(v <= tree[c].m ) update(L(c),p,v,value);
	else if(p > tree[c].m) update(R(c),p,v,value);
	else {
		update(L(c),p,tree[c].m,value);
		update(R(c),tree[c].m+1,v,value);
	}
	Pushup(c);
}
예제 #4
0
파일: 1166.cpp 프로젝트: 8cbx/code-area
void update(int p,int add,int l,int r,int rt)
{
    if(l==r)
    {
        sum[rt]+=add;
        return;
    }
    int m=(l+r)>>1;
    if(p<=m)
    {
        update(p,add,lson);
    }
    else
    {
        update(p,add,rson);
    }
    Pushup(rt);
}
예제 #5
0
파일: 1546.c 프로젝트: bitchbitch/ACM-ICPC
void build(int c, int p , int v)
{
	tree[c].l = p ; 
	tree[c].r = v ;
	tree[c].m = (p+v)/2;
	tree[c].sum = 0 ; 
	tree[c].c = 0;
	tree[c].f = 0 ;
	if(p == v ){
		if(str[p] == '('){
			tree[c].c = 1; 
			tree[c].sum = 1; 
		}
		else {
			tree[c].c = -1;
			tree[c].sum = -1;
		}
		return ;
	}
	build(L(c),p,tree[c].m);
	build(R(c),tree[c].m+1,v);
	Pushup(c);
}