• <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ì)心的觀察別人,要隨時注意才能保護(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;//測度
             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 小果子 閱讀(1195) 評論(0)  編輯 收藏 引用 所屬分類: Acm
            av色综合久久天堂av色综合在| 国产精品热久久无码av| 婷婷久久精品国产| 久久亚洲AV永久无码精品| 人妻无码精品久久亚瑟影视| 日韩十八禁一区二区久久 | 伊人色综合九久久天天蜜桃| 久久免费视频1| AV无码久久久久不卡蜜桃| 久久精品国产亚洲AV电影| 一本大道久久a久久精品综合| 久久性生大片免费观看性| 99久久国产宗和精品1上映| 狠狠色丁香久久婷婷综合五月| 久久99精品久久久久久水蜜桃| 免费精品久久天干天干| 久久99国产精品一区二区| 久久久久亚洲av毛片大| 午夜欧美精品久久久久久久| 大香网伊人久久综合网2020| 久久无码高潮喷水| 久久国产精品久久| 国产精品久久久久久久app| 久久精品成人免费网站| 欧美亚洲日本久久精品| 久久精品视频网| 久久夜色精品国产噜噜亚洲a| 久久精品www| 久久久久国产精品人妻| 国产精品九九久久精品女同亚洲欧美日韩综合区 | 一本久久a久久精品vr综合| 久久久久九九精品影院| 欧美综合天天夜夜久久| 久久久精品人妻一区二区三区蜜桃| 天堂无码久久综合东京热| 99久久无码一区人妻| 91视频国产91久久久| 日产精品久久久久久久| 亚洲va久久久久| 久久久久国产一级毛片高清板| 伊人久久综在合线亚洲2019|