• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            xiaoguozi's Blog
            Pay it forword - 我并不覺的自豪,我所嘗試的事情都失敗了······習(xí)慣原本生活的人不容易改變,就算現(xiàn)狀很糟,他們也很難改變,在過程中,他們還是放棄了······他們一放棄,大家就都是輸家······讓愛傳出去,很困難,也無法預(yù)料,人們需要更細(xì)心的觀察別人,要隨時(shí)注意才能保護(hù)別人,因?yàn)樗麄兾幢刂雷约阂裁础ぁぁぁぁ?/span>
            //回憶系列:
            //可以優(yōu)化的,去除重復(fù)點(diǎn),我這沒這一步,而且我比較懶,直接把離散這一步省略了,直接替代了
            //不過離散化+線段樹思想是不變的,注釋比較少
              1//segment tree template
              2#include <iostream>
              3#include <algorithm>
              4
              5using namespace std;
              6struct Eage{
              7    long long xi;
              8    long long yu,yd;
              9    int flag;
             10    bool operator<(const Eage& e)const{
             11        return xi<e.xi;
             12    }
            ;
             13}
            line[80210];
             14long long dy[80210];
             15
             16struct Tnode{
             17    //point left,right child
             18    Tnode *lc,*rc;
             19    //segment devide
             20    int left,right;
             21
             22    //extra
             23    int cnt;//是否覆蓋
             24    long long len;//測(cè)度
             25    long long yu,yd;
             26    //construct function
             27    Tnode(int data=0,int l=0,int r=0,Tnode*lp=0,Tnode*rp=0)
             28            :left(l),right(r),lc(lp),rc(rp){
             29                len=yu=yd=0.0;
             30                cnt=0;
             31    }
            ;
             32}
            ;
             33
             34//maxsize number of Tnode
             35const int N=80002;
             36
             37//static allocate memory for Tnode [a,b] node_size=2*(b-a)+1 for [i,i+1]
             38Tnode node[N<<1];
             39//count for usage Tnode array
             40int cnt=0;
             41
             42//make a new node ,return Tnode*
             43Tnode* new_node(){
             44    Tnode* p=&node[cnt++];
             45    memset(p,0,sizeof(Tnode));
             46    return p;
             47}

             48
             49//make tree ,return Tnode* which is root
             50//parament: [left,right]
             51Tnode* make_tree(int left,int right){
             52    //make a new Tnode 
             53    Tnode* root=new_node();
             54    //Initial the Tndoe
             55    root->left=left,root->right=right;
             56    
             57    if(left+1==right){
             58        root->yu=dy[right];
             59        root->yd=dy[left];
             60        return root;
             61    }
            else{
             62        int mid=(left+right)>>1;
             63        root->lc=make_tree(left,mid);
             64        root->rc=make_tree(mid,right);
             65        return root;
             66    }

             67}

             68long long CalLen(Tnode* root){
             69    root->len=0;
             70    if(root->cnt>0){
             71        root->len=dy[root->right] - dy[root->left];
             72        return root->len;
             73    }

             74    if(root->lc)root->len=root->lc->len;
             75    if(root->rc)root->len+=root->rc->len;
             76
             77    return root->len;
             78}
            ;
             79void Update(Tnode* root,Eage data){
             80    if(dy[root->left]>=data.yd&&dy[root->right]<=data.yu){
             81        root->cnt+=data.flag;
             82        CalLen(root);
             83        return ;
             84    }

             85    int mid=(root->left+root->right)>>1;
             86    if(dy[mid]>=data.yu){
             87        Update(root->lc,data);
             88    }
            else if(dy[mid]<=data.yd){
             89        Update(root->rc,data);
             90    }
            else{
             91        Eage tmp=data;
             92        tmp.yu=dy[mid];
             93        Update(root->lc,tmp);
             94
             95        tmp=data;
             96        tmp.yd=dy[mid];
             97        Update(root->rc,tmp);
             98    }

             99    CalLen(root);
            100    return ;
            101}

            102int main()
            103{
            104    int e=1;
            105    int n;
            106    while(cin>>n){
            107        cnt=0;
            108        long long x1,y1,x2,y2;
            109        for(int i=1;i<=2*n;i+=2){
            110            cin>>x1>>x2>>y2;
            111            y1=0;
            112            line[i].xi=x1,line[i].yd=y1,line[i].yu=y2,line[i].flag=1;
            113            line[i+1].xi=x2,line[i+1].yd=y1,line[i+1].yu=y2,line[i+1].flag=-1;
            114            dy[i]=y1;
            115            dy[i+1]=y2;
            116        }

            117        sort(line+1,line+2*n+1);
            118        sort(dy+1,dy+2*n+1);
            119        Tnode *root=make_tree(1,2*n);
            120
            121        long long area=0;
            122        Update(root,line[1]);
            123        for(int i=2;i<=2*n;i++){
            124            area+=root->len*(line[i].xi-line[i-1].xi);
            125            Update(root,line[i]);
            126        }

            127        //printf("Test case #%d\n",e++);
            128        printf("%lld\n",area);
            129    }

            130    return 0;
            131}
            ..
            http://acm.pku.edu.cn/JudgeOnline/problem?id=3277
            posted on 2009-03-09 14:27 小果子 閱讀(1196) 評(píng)論(0)  編輯 收藏 引用 所屬分類: Acm
            精品国产青草久久久久福利| 久久无码人妻一区二区三区午夜| 国产精品欧美久久久久无广告 | 日韩影院久久| 亚洲伊人久久精品影院| 久久噜噜电影你懂的| 久久婷婷是五月综合色狠狠| 精品国产福利久久久| 久久影视综合亚洲| 久久久久久免费一区二区三区| 开心久久婷婷综合中文字幕| www性久久久com| 久久国产劲爆AV内射—百度| 久久精品国产精品国产精品污| 久久久久无码精品| 国产精品久久久久aaaa| 人人狠狠综合久久亚洲高清| 久久精品男人影院| 久久综合狠狠综合久久| 一级做a爰片久久毛片免费陪| 国产精品熟女福利久久AV| 99999久久久久久亚洲| 精品国产乱码久久久久久人妻 | 久久国产乱子精品免费女| 热99RE久久精品这里都是精品免费 | 久久综合久久自在自线精品自| 国内精品伊人久久久久妇| 久久久久国产视频电影| 国产精品gz久久久| 欧美久久精品一级c片片| 色妞色综合久久夜夜| 亚洲愉拍99热成人精品热久久 | 久久99精品九九九久久婷婷 | 一本色道久久88—综合亚洲精品| 亚洲精品成人网久久久久久| 亚洲国产精品成人久久蜜臀| 伊人久久成人成综合网222| 久久久久久综合网天天| 一本一本久久aa综合精品| 老色鬼久久亚洲AV综合| 77777亚洲午夜久久多喷|