• <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 閱讀(282) 評論(0)  編輯 收藏 引用 所屬分類: 線段樹|樹狀數組POJ
            久久66热人妻偷产精品9| 久久天堂电影网| 无码人妻久久一区二区三区蜜桃| 色妞色综合久久夜夜| 久久久国产精华液| 欧美国产精品久久高清| 亚洲国产精品无码久久久久久曰| 久久高潮一级毛片免费| 久久国产影院| 欧美激情精品久久久久久久九九九 | 亚洲午夜精品久久久久久人妖| 99精品久久精品| 精品久久久久久久久午夜福利| 久久亚洲欧美国产精品 | 老司机午夜网站国内精品久久久久久久久 | 欧美午夜A∨大片久久| 亚洲人成网站999久久久综合| 久久午夜夜伦鲁鲁片免费无码影视| 国产一区二区久久久| 久久久久久久波多野结衣高潮| 国产免费久久精品丫丫| 国産精品久久久久久久| 香港aa三级久久三级老师2021国产三级精品三级在 | 久久精品蜜芽亚洲国产AV| 久久夜色精品国产噜噜亚洲a| 麻豆久久| 久久精品www人人爽人人| 亚洲国产精品久久久久婷婷老年| 亚洲国产成人久久综合一| 久久婷婷久久一区二区三区| 香蕉久久永久视频| 久久久av波多野一区二区| a级成人毛片久久| 亚洲精品乱码久久久久久蜜桃| 久久狠狠高潮亚洲精品| 亚洲成人精品久久| 久久天天躁狠狠躁夜夜躁2014| 久久久精品午夜免费不卡| 久久久久久亚洲精品影院| 久久久久久久99精品免费观看| 偷窥少妇久久久久久久久|