• <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>

            ACM PKU 1828 Monkeys' Pride

            http://acm.pku.edu.cn/JudgeOnline/problem?id=1828
            看了discuss,很多同學對題意理解有誤(剛開始我也理解錯了)
            主要是這句:If a monkey lives at the point (x0, y0), he can be the king only if there is no monkey living at such point (x, y) that x>=x0 and y>=y0

            成為猴王的條件是,沒有任何的一個猴子的x坐標和y坐標都大于它,而不是說猴王的x和y都要最大.
            ok,算法也出來了,簡單地說: 先對x快速排序,然后統計y  , 時間效率是O(n^lgn)
            具體細節要自己體會,這題挺經典的.另外快速排序的方法,雖然我也不是第一次用到了,但是仍然不熟練,到網上查了語法再做的.
            #include"stdio.h"
            #include
            "stdlib.h"

             
             typedef 
            struct{
                
            int x;
                 
            int y;
             }
            node[50001];
             


             
            int cmp(const void *pl, const void *pr){   ///按照x從小到大排序
                node *p1 = (node*)pl; 
                 node 
            *p2 = (node*)pr;
                 
            if(p1->== p2->x)           
                     
            return p1->- p2->y;
                
            return p1->- p2->x;
             }

             

            void main(){
                 
            int num,i,total,maxy;
                 
            while(scanf("%d",&num) && num){
                     
            for(i=0;i<num;i++)
                         scanf(
            "%d%d",&nodes[i].x,&nodes[i].y);
                     qsort(nodes, num, 
            sizeof(node), &cmp); //按照x從小到大排序
                   total=1;           //最后一個猴子的x最大,所以至少有一個猴王. 往前掃描,如果出現某個猴子的y大于當前最大y,total+1
                     maxy=nodes[num-1].y;
                    
            for(i=num-2;i>=0;i--){
                         
            if(maxy<nodes[i].y){
                            maxy
            =nodes[i].y;
                             total
            ++;
                         }

                     }

                     printf(
            "%d\n",total);
                 }

                 
            return;
             }



            另外,在PKU上編譯器效率的問題:

            同樣的程序,我測試了3次.
            include的時候,如果用iostream,在  C++編譯器下測試,Memory是476K ,時間280MS
            換成 stdio.h + stdlib.h ,在C編譯器下Memory是464K ,時間171MS
            如果是stdio.h + stdlib.h在C++的編譯器下測試呢?Memory是464K ,時間155MS

            也就是說,同樣的測試數據,要達到最好的效率,應該用純C的方式寫程序,并選擇C++編譯器judge程序.

            posted on 2007-09-21 01:14 流牛ζ木馬 閱讀(1783) 評論(8)  編輯 收藏 引用

            評論

            # re: ACM PKU 1828 Monkeys' Pride 2008-12-02 18:12 aa

            這題題目改了吧。。。你這代碼過不了。  回復  更多評論   

            # re: ACM PKU 1828 Monkeys' Pride 2009-08-01 09:33 幻風

            明顯過不了吧?
            4
            3 1
            3 2
            3 0
            2 2
              回復  更多評論   

            # re: ACM PKU 1828 Monkeys' Pride 2010-07-09 00:15 WallacePatti29

            This is what I was exploring for a while! Thank you for this topic around college! Once someone state that In union there is might. Our high qualified team can help you in writing <a href="http://essaysexperts.com/">term paper</a>.  回復  更多評論   

            # re: ACM PKU 1828 Monkeys' Pride 2010-07-09 16:43 dissertation writing service

            Your well done article about this post comes side by side with the student dissertation. Hence, you must perform for dissertation service.   回復  更多評論   

            # re: ACM PKU 1828 Monkeys' Pride 2010-07-09 17:29 thesis

            Eventually, We have found best article just about this good post? We suggest to search the buy thesis or purchase french dissertation, just because this helps in getting the best grade if you have buy dissertation.   回復  更多評論   

            # re: ACM PKU 1828 Monkeys' Pride 2010-09-06 14:54 resume writing service

            The clients rely on our
            resume service cause they are very responsible! This corporation performs resume writing to fit the precise field of science you wish.  回復  更多評論   

            # re: ACM PKU 1828 Monkeys' Pride 2010-10-07 14:55 buying essays

            To have good grades, some students have to decide if they are willing to accomplish the custom essay paper online or buy an essay paper of the best upper-class.   回復  更多評論   

            # re: ACM PKU 1828 Monkeys' Pride 2012-01-13 07:40 book reports

            University students would not have complications with their wars essays creating, because the papers writing corporations are able to sell essay of high quality.   回復  更多評論   

            # re: ACM PKU 1828 Monkeys' Pride 2012-04-17 19:04 buy essay

            Some time before I faced a lot of complications with essays writing. Nevertheles, my friend suggested to buy essays online. Thus, at this moment I have my A+.   回復  更多評論   

            <2025年5月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            導航

            統計

            公告

            MY Email/MSN :mars1021@163.com QQ : 27402040 流牛ζ木馬

            常用鏈接

            留言簿(6)

            隨筆檔案

            相冊

            搜索

            最新隨筆

            最新評論

            閱讀排行榜

            評論排行榜

            久久免费美女视频| 久久婷婷午色综合夜啪| 久久精品国产亚洲精品2020| 狠狠色丁香久久婷婷综合五月| 国产精品美女久久久久| 99999久久久久久亚洲| 久久一区二区三区免费| 国内精品久久国产| 伊人久久免费视频| 久久久无码精品亚洲日韩按摩| 99久久成人18免费网站| 亚洲国产精品一区二区三区久久 | 欧美无乱码久久久免费午夜一区二区三区中文字幕 | 色青青草原桃花久久综合| 色婷婷综合久久久久中文| 亚洲?V乱码久久精品蜜桃| 久久天堂AV综合合色蜜桃网| 久久精品亚洲福利| 91精品国产91热久久久久福利| 人人妻久久人人澡人人爽人人精品| 久久国产精品-国产精品| 青青青国产精品国产精品久久久久| 亚洲精品美女久久久久99小说| 精品久久久久中文字幕日本| 国产一区二区久久久| 国产精品久久久久乳精品爆 | 国产亚洲综合久久系列| yy6080久久| 久久婷婷人人澡人人| 精品欧美一区二区三区久久久| 狠狠精品久久久无码中文字幕 | 久久亚洲国产精品123区| 国产一级做a爰片久久毛片| 午夜人妻久久久久久久久| 久久婷婷激情综合色综合俺也去| 婷婷久久综合九色综合绿巨人| 国内精品久久久久国产盗摄| 欧美一区二区精品久久| 婷婷久久综合九色综合98| 久久青青草原国产精品免费| 久久国产精品-国产精品|