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

            ______________白白の屋
            posts - 182, comments - 102, trackbacks - 0, articles - 0
            <2010年8月>
            25262728293031
            1234567
            891011121314
            15161718192021
            22232425262728
            2930311234

            常用鏈接

            留言簿(24)

            隨筆分類(332)

            隨筆檔案(182)

            FRIENDS

            搜索

            積分與排名

            最新隨筆

            最新評論

            閱讀排行榜

            評論排行榜

            MiYu原創, 轉帖請注明 : 轉載自 ______________白白の屋    

             

            題目地址:

                http://acm.hdu.edu.cn/showproblem.php?pid=1541 

            題目描述:

            Stars

            Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
            Total Submission(s): 857    Accepted Submission(s): 320


            Problem Description
            Astronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars that are not higher and not to the right of the given star. Astronomers want to know the distribution of the levels of the stars. 



            For example, look at the map shown on the figure above. Level of the star number 5 is equal to 3 (it's formed by three stars with a numbers 1, 2 and 4). And the levels of the stars numbered by 2 and 4 are 1. At this map there are only one star of the level 0, two stars of the level 1, one star of the level 2, and one star of the level 3. 

            You are to write a program that will count the amounts of the stars of each level on a given map.
             

            Input
            The first line of the input file contains a number of stars N (1<=N<=15000). The following N lines describe coordinates of stars (two integers X and Y per line separated by a space, 0<=X,Y<=32000). There can be only one star at one point of the plane. Stars are listed in ascending order of Y coordinate. Stars with equal Y coordinates are listed in ascending order of X coordinate.
             

            Output
            The output should contain N lines, one number per line. The first line contains amount of stars of the level 0, the second does amount of stars of the level 1 and so on, the last line contains amount of stars of the level N-1.
             

            Sample Input
            5 1 1 5 1 7 1 3 3 5 5
             

            Sample Output
            1 2 1 1 0
             

            題目分析 :

               題目的意思就是計算 星星的左下角 ( 包括 正左, 正下 ) 有多少顆其他的星星, 左下角星星的個數就是這個星星的等級,  題目要求輸出每個等級星星的個數. 

               具體做法:   另外開個數組存儲星星的等級,比他小的數的個數作為下標,即等級,每出現一次,數組加一,com數組的大小即為它存儲數據的最大值。 

            代碼如下 :

             

             /*

            MiYu原創, 轉帖請注明 : 轉載自 ______________白白の屋

                      http://www.cnblog.com/MiYu

            Author By : MiYu

            Test      : 1

            Program   : 1541

            */


            #include <iostream>

            using namespace std;

            const int MAX = 32005;

            #define lowbit(x) ((x)&(-x))

            int com[MAX], res[MAX], N;

            void modify ( int pos, int val ){

                 while ( pos <= MAX ){

                        com[pos] += val;

                        pos += lowbit(pos);  

                 } 

            }

            int quy ( int x ){

                int sum = 0;

                while ( x > 0 ){

                       sum += com[x];

                       x -= lowbit(x);

                } 

                return sum;

            }

            int main (int x)

            {

                while ( scanf ( "%d",&N ) != EOF ){

                        memset ( com,0,sizeof (com) ); memset ( res,0,sizeof (res) );

                        for ( int i = 1; i <= N; ++ i ){

                              scanf ( "%d%*d", &x ); 

                              x++;

                              res[ quy(x) ] ++;  modify ( x,1 );

                        }

                        for ( int i = 0; i < N; ++ i )

                              printf ( "%d\n",res[i] );

                }

                return 0;

            }


             

             

            波多野结衣AV无码久久一区| 伊人色综合久久天天| 2021国产精品久久精品| 亚洲欧美日韩中文久久| 精品一区二区久久久久久久网站| 久久99久久成人免费播放| 久久九九兔免费精品6| 久久99国产精品久久99果冻传媒| 久久亚洲AV永久无码精品| 日韩精品久久久肉伦网站| 激情久久久久久久久久| 亚洲va中文字幕无码久久不卡| 久久91精品久久91综合| 中文字幕无码av激情不卡久久| 狠狠88综合久久久久综合网 | 欧美色综合久久久久久| 亚洲精品乱码久久久久久中文字幕 | 狠狠色伊人久久精品综合网| 久久天天躁狠狠躁夜夜avapp | 久久久久久国产a免费观看黄色大片| 久久精品国产清高在天天线| 亚洲国产成人精品91久久久 | 色偷偷偷久久伊人大杳蕉| 亚洲精品乱码久久久久久不卡| 2021少妇久久久久久久久久| 国产亚洲精品久久久久秋霞| 久久无码一区二区三区少妇| 国产午夜精品久久久久九九| 久久久噜噜噜www成人网| 亚洲va中文字幕无码久久| 亚洲一级Av无码毛片久久精品| 精品久久人人做人人爽综合| 大美女久久久久久j久久| 97久久综合精品久久久综合| 久久国产精品99精品国产| 亚洲午夜久久久久久久久电影网| 久久天天躁狠狠躁夜夜不卡| 奇米影视7777久久精品人人爽| 狠狠色丁香久久婷婷综合蜜芽五月| 午夜精品久久久久久久无码| 久久经典免费视频|