void BuildTree(int i,int left,int right){
node[i].left=left;
node[i].right=right;
node[i].value=0;
if(left==reght){//????3¤?è?a0ê±£??áê?μY1é
father[left]=i;//?ü?aμà?3ò???μ???ó|μ?Dòo?£??aá??üD?ê±′ó??íùé??üD?
return;
}
BuildTree(i<<1,left,(right+left)<<1);
BuildTree(i<<1+1,left(right+left)<<1+1,right);
}
void Updata(int r){//′ó??íùé??üD? £??a??μ?±?éíò??-?úoˉêyía?üD?1y
if(r==1) return;//?üD?μ??¥á?
int fu=r<<1;//?ó???áμ?w
int a=node[r>>1].value;
int b=node[r>>1+1].value;
//?óo¢×ó?áμ?
//do someing ?ù?Yìa??òa?ó×??àó|2ù×÷
//?ó×?′ó?μ
node[fu].value=max(a,b);
Updata(r<<1);// ′ó??íùé??üD?
}
原文:https://www.cnblogs.com/OfflineBoy/p/13893405.html