キャスター

4309 ワード

http://acm.hdu.edu.cn/showproblem.php?pid=3265
キャスター
Time Limit:5000/2000 MS(Java/Others)    メモリLimit:32768/32768 K(Java/Others)Total Submission(s):5762    Acceepted Submission(s):1363
Problem Description
Ted has a new house with a huge window.In this big summer,Ted decides to decorate the window with some posters to prevent the glare outside.All things that Ted can find arctangles. 
However,Ted is such a picky Guit,he cuts a rectanglar hold to remove the ugly.So before he pastes a poster on the window,he cuts a rectanglar hold to remove the ugly party.Ted alis the soreatcast 
Ted wants to know the total ara of the window covered by posters.Now it is your job to figur it out.
To make your job easure,we assim that the window is a rectanle located in a rectanglar coordiname.The window’s bottom-left Coner is position(0,0)and top-right coner is the.s.s。the edges of the posters and the edges of the holes on the posters are all parallel with the coordinate axes. 
 
Input
The input contains several test cases.For each test case,the first line contains a single integer N(0
The input ends with a line of single zero.
 
Output
For each test case、output a single line with the total ara of window covered by poster s.
 
Sample Input
 
   
2 0 0 10 10 1 1 9 9 2 2 8 8 3 3 7 7 0
 

Sample Output
 
   
56
 

Source
2009 Asia Ningbo Regional Contest Hosted by NIT
 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
const int SIZE=5e4+10;
using namespace std;
struct sge{
    int l,r,h,s;
    sge(){}
    sge(int a,int b,int c,int d):l(a),r(b),h(c),s(d){}
    bool operator>1;
        calc(lson);
        calc(rson);
    }
}
void pushdown(int l,int r,int rt){
    if(col[rt]){
        col[rt<<1]+=col[rt];
        col[rt<<1|1]+=col[rt];
        int m=(l+r)>>1;
        calc(lson);
        calc(rson);
        col[rt]=0;
        calc(l,r,rt);
    }
}
int Bin(int key,int n,int X[]){
    int l=0,r=n-1;
    while(l<=r){
        int m=(l+r)>>1;
        if(X[m]==key)return m;
        else if(X[m]>key)r=m-1;
        else l=m+1;
    }
    return -1;
}
void update(int L,int R,int c,int l,int r,int rt){
    if(L<=l&&r<=R){
        col[rt]+=c;
        calc(l,r,rt);
        return ;
    }
    pushdown(l,r,rt);
    int m=(l+r)>>1;
    if(L<=m)update(L,R,c,lson);
    if(R>m)update(L,R,c,rson);
    pushup(l,r,rt);
    calc(l,r,rt);
}
int main()
{
    //freopen("F://in.txt","r",stdin);
    int n,x1,x2,x3,x4,y1,y2,y3,y4;
    while(scanf("%d",&n)&&n){
        int tot=0;
        __int64 cnt=0;
        for(int i=0;i