if(tt[pos].lp + 1 == tt[pos].rp)
return;
int mid = tt[pos].getmid();
if(LL[id].lp >= mid){
update(pos * 2 + 1,id);
}
else if(LL[id].rp <= mid){
update(pos * 2,id);
}
else{
update(pos * 2,id);
update(pos * 2 + 1,id);
}
getlen(pos);
}
int main(){
//freopen(“1.txt”,“r”,stdin);
int a,b,c,d,tot = 0;
while(scanf(“%d%d%d%d”,&a,&b,&c,&d) && (a + b + c + d) != -4){
tot = 0;
LL[tot].lp = a; LL[tot].rp = c; LL[tot].value = d; LL[tot++].cnt = 1;
LL[tot].lp = a; LL[tot].rp = c; LL[tot].value = b; LL[tot++].cnt = -1;
int x1,y1,x2,y2;
while(1){
scanf(“%d%d%d%d”,&x1,&y1,&x2,&y2);
if(x1 + y1 + x2 + y2 == -4)
break;
LL[tot].lp = x1; LL[tot].rp = x2; LL[tot].value = y2; LL[tot++].cnt = 1;
LL[tot].lp = x1; LL[tot].rp = x2; LL[tot].value = y1; LL[tot++].cnt = -1;
}
built_tree(0,N,1);
sort(LL,LL+tot,cmp);
update(1,0);
long long ans = 0;
for(int i = 1; i < tot; ++i){
ans += tt .len * (LL[i-1].value - LL[i].value);
update(1,i);
}
printf(“%lld\n”,ans);
}
return 0;
}