• <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; //本區(qū)間是否已經(jīng)被完全覆蓋 
                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;
                }
                
            //要更新根節(jié)點(diǎn)的覆蓋情況
                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; //去掉重復(fù)元素
                    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 -- ) { // 從后往前看板是否看得見(jiàn)
                        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 閱讀(288) 評(píng)論(0)  編輯 收藏 引用 所屬分類(lèi): 線(xiàn)段樹(shù)|樹(shù)狀數(shù)組POJ
            少妇被又大又粗又爽毛片久久黑人| 久久综合九色综合欧美就去吻| 国产精品久久久久久久人人看| 久久热这里只有精品在线观看| 久久人人爽人人爽人人爽| 久久亚洲精品国产精品| 中文字幕成人精品久久不卡| 亚洲国产成人久久综合区| 亚洲AV无码一区东京热久久| 久久精品国产精品青草app| 国产亚洲精午夜久久久久久| 亚洲国产精品无码久久| 精品免费久久久久国产一区| 一本久久知道综合久久| 久久精品一区二区影院 | 久久久久久A亚洲欧洲AV冫 | 久久精品aⅴ无码中文字字幕不卡| 亚洲AV日韩AV永久无码久久| 久久精品这里只有精99品| 欧美va久久久噜噜噜久久| 亚洲午夜精品久久久久久浪潮| 久久精品九九亚洲精品天堂| 久久这里只精品99re66| 国产精品成人久久久久久久| 精品免费久久久久久久| 狠狠色丁香久久婷婷综合| 久久伊人色| 久久久久这里只有精品| 国产高清美女一级a毛片久久w| 伊人久久大香线蕉亚洲五月天| 久久精品无码一区二区三区免费 | 国产精品久久久久久久久久免费| 久久婷婷五月综合97色一本一本 | 香蕉久久夜色精品国产尤物| 热99re久久国超精品首页| 精品国产VA久久久久久久冰 | 亚洲综合婷婷久久| 国产精品久久成人影院| 99re久久精品国产首页2020| 嫩草伊人久久精品少妇AV| 久久久久久午夜成人影院|