• <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>
            #include <iostream>
            #include 
            <algorithm>
            #include 
            <math.h>
            using namespace std;
            int n;
            struct CPost
            {
                
            int L,R;
            };
            CPost posters[
            10100];
            int x[20200];
            int hash[10000010];
            struct CNode 
            {
                
            int L,R;
                
            bool bCovered; //本區間是否已經被完全覆蓋 
                CNode * pLeft, * pRight;
            };
            CNode Tree[
            100000];
            int nNodeCount = 0;
            int Mid( CNode * pRoot)
            {
                
            return (pRoot->+ pRoot->R)/2;
            }
            void BuildTree( CNode * pRoot, int L, int R)
            {
                pRoot
            ->= L;
                pRoot
            ->= R;
                pRoot
            ->bCovered = false;
                
            if( L == R )
                    
            return;
                nNodeCount 
            ++;
                pRoot
            ->pLeft = Tree + nNodeCount;
                nNodeCount 
            ++;
                pRoot
            ->pRight = Tree + nNodeCount;
                BuildTree( pRoot
            ->pLeft,L,(L+R)/2);
                BuildTree( pRoot
            ->pRight,(L+R)/2 + 1,R);
            }
            bool Post( CNode  *pRoot, int L, int R)
            {
                
            if( pRoot->bCovered )
                    
            return false;
                
            if( pRoot->== L && pRoot->== R) {
                    pRoot
            ->bCovered = true;
                    
            return true;
                }
                
            bool bResult ;
                
            if( R <= Mid(pRoot) ) 
                    bResult 
            = Post( pRoot->pLeft,L,R);
                
            else if( L >= Mid(pRoot) + 1)
                    bResult 
            = Post( pRoot->pRight,L,R);
                
            else {
                    
            bool b1 = Post(pRoot->pLeft ,L,Mid(pRoot));
                    
            bool b2 = Post( pRoot->pRight,Mid(pRoot) + 1,R);
                    bResult 
            = b1 || b2;
                }
                
            //要更新根節點的覆蓋情況
                if( pRoot->pLeft->bCovered && pRoot->pRight->bCovered )
                    pRoot
            ->bCovered = true;
                
            return bResult;
            }
            int main()
            {
                
            int t;
                
            int i,j,k;
                scanf(
            "%d",&t);
                
            int nCaseNo = 0;
                
            while(t--) {
                    nCaseNo 
            ++;
                    scanf(
            "%d",&n);
                    
            int nCount = 0;
                    
            for( i = 0;i < n;i ++ )  {
                        scanf(
            "%d%d"& posters[i].L,& posters[i].R );

                        x[nCount
            ++= posters[i].L;
                        x[nCount
            ++= posters[i].R;
                    }
                    sort(x,x
            +nCount);
                    nCount 
            = unique(x,x+nCount) - x; //去掉重復元素
                    for( i = 0;i < nCount;i ++ )
                        hash[x[i]] 
            = i;
                    nNodeCount 
            = 0;
                    BuildTree( Tree,
            0,nCount - 1);
                    
            int nSum = 0;
                    
            for( i = n - 1;i >= 0;i -- ) { // 從后往前看板是否看得見
                        if( Post(Tree,hash[posters[i].L],hash[posters[i].R]))
                            nSum 
            ++;
                    }
                    printf(
            "%d\n",nSum);
                }
                
            return 0;
            }
            posted on 2010-07-28 22:45 Vontroy 閱讀(287) 評論(0)  編輯 收藏 引用 所屬分類: 線段樹|樹狀數組POJ
            99久久免费国产精品| 久久精品中文字幕第23页| 久久精品aⅴ无码中文字字幕不卡 久久精品成人欧美大片 | 久久久久综合中文字幕| 久久99这里只有精品国产| 久久九九久精品国产免费直播| 久久国产AVJUST麻豆| 久久99精品国产| 蜜臀久久99精品久久久久久 | 国产精品久久久久蜜芽| 7777精品久久久大香线蕉| AV色综合久久天堂AV色综合在| 久久99精品久久久久久噜噜| 久久无码高潮喷水| 夜夜亚洲天天久久| 久久婷婷成人综合色综合| 国产精品免费久久久久电影网| 伊人久久综合精品无码AV专区 | 日韩中文久久| 久久香蕉一级毛片| 中文精品久久久久人妻不卡| 色综合久久中文色婷婷| 久久天天躁狠狠躁夜夜躁2O2O| 久久噜噜久久久精品66| 99久久精品费精品国产一区二区| 亚洲欧洲精品成人久久奇米网| 99久久人妻无码精品系列| 久久精品国产欧美日韩99热| 国产成人精品综合久久久| 久久精品国产第一区二区三区| 亚洲αv久久久噜噜噜噜噜| 伊人久久大香线蕉av不变影院| 国产精品成人99久久久久| 精品国产一区二区三区久久| 久久精品国产亚洲AV香蕉| 久久经典免费视频| 亚洲精品综合久久| 久久久高清免费视频| 区久久AAA片69亚洲| 久久无码中文字幕东京热| 久久天天躁狠狠躁夜夜avapp|