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

            我希望你是我獨家記憶

            一段永遠封存的記憶,隨風而去
            posts - 263, comments - 31, trackbacks - 0, articles - 3
               :: 首頁 :: 新隨筆 ::  :: 聚合  :: 管理

            PKU——1088——(滑雪DP)

            Posted on 2008-08-21 10:58 Hero 閱讀(158) 評論(0)  編輯 收藏 引用 所屬分類: 代碼如詩--ACM
             1 //1088 Accepted 440K 16MS C++ 1725B 
             2 
             3 //DP--排序后DP
             4 //dp[i][j] = fmax( dp[i][j], dp[m][n]+1 ) ;
             5 //[m][n]是和[i][j]相鄰的且val比[i][j]小的坐標
             6 
             7 #include <stdio.h>
             8 #include <stdlib.h>
             9 #include <string.h>
            10 
            11 const int size = 120 ;
            12 int data[size][size] ;
            13 int dp[size][size] ;
            14 struct NODE
            15 {
            16     int row ;
            17     int col ;
            18     int val ;
            19 };
            20 struct NODE node[size*size] ;
            21 int cnode = 0 ;
            22 int row, col ;
            23 
            24 int fmax( int a, int b )
            25 {
            26     return a > b ? a : b ;
            27 }
            28 
            29 void input() 
            30 {
            31     memset( data, -1sizeof(data) ) ; cnode = 0 ;
            32     forint i=1; i<=row; i++ ) forint j=1; j<=col; j++ ) {
            33         scanf( "%d"&data[i][j] ) ;
            34         node[cnode].row = i ; node[cnode].col = j ; node[cnode++].val = data[i][j] ;
            35     }
            36 }
            37 
            38 int cmp( const void *a, const void *b )
            39 {
            40     struct NODE *= (struct NODE *)a ;
            41     struct NODE *= (struct NODE *)b ;
            42     return c->val - d->val ;
            43 }
            44 
            45 void process()
            46 {
            47     qsort( node, cnode, sizeof(node[0]), cmp ) ;//從小到大排序
            48 
            49     memset( dp, 0sizeof(dp) ) ;
            50 
            51     int curc, curr ;
            52     forint i=0; i<cnode; i++ )
            53     {
            54         curr = node[i].row ; curc = node[i].col ; dp[curr][curc] = 1 ;//初始化
            55         if( data[curr][curc] > data[curr][curc-1] )
            56             dp[curr][curc] = fmax( dp[curr][curc], dp[curr][curc-1]+1 ) ;
            57         if( data[curr][curc] > data[curr][curc+1] )
            58             dp[curr][curc] = fmax( dp[curr][curc], dp[curr][curc+1]+1 ) ;
            59         if( data[curr][curc] > data[curr-1][curc] )
            60             dp[curr][curc] = fmax( dp[curr][curc], dp[curr-1][curc]+1 ) ;
            61         if( data[curr][curc] > data[curr+1][curc] )
            62             dp[curr][curc] = fmax( dp[curr][curc], dp[curr+1][curc]+1 ) ;
            63     }
            64 }
            65 
            66 void output()
            67 {
            68     int maxlen = -1 ;
            69     forint i=1; i<=row; i++ ) forint j=1; j<=col; j++ )
            70     {
            71         if( dp[i][j] > maxlen ) maxlen = dp[i][j] ;
            72     }
            73 
            74     printf( "%d\n", maxlen ) ;
            75 }
            76 
            77 int main()
            78 {
            79     while( scanf( "%d %d"&row, &col ) != EOF )
            80     {
            81         input() ;
            82 
            83         process() ;
            84 
            85         output() ;
            86     }
            87 
            88     return 0 ;
            89 }
            亚洲国产成人久久精品动漫| 久久婷婷色香五月综合激情| 久久九九亚洲精品| 久久久久久噜噜精品免费直播| 久久午夜夜伦鲁鲁片免费无码影视 | 精品久久久久久久无码| 日韩欧美亚洲综合久久影院d3| 中文精品99久久国产| 麻豆精品久久精品色综合| 一级做a爰片久久毛片看看| 精品久久香蕉国产线看观看亚洲| 久久久WWW成人免费毛片| 91精品国产高清91久久久久久| 久久人搡人人玩人妻精品首页| 日韩人妻无码一区二区三区久久| 久久99国产一区二区三区| 久久久久亚洲av无码专区| 日日狠狠久久偷偷色综合免费 | 亚洲一区中文字幕久久| 奇米影视7777久久精品人人爽| 四虎国产精品免费久久5151| 久久久久国产精品熟女影院| 超级97碰碰碰碰久久久久最新| 久久精品中文字幕第23页| 99麻豆久久久国产精品免费| 精品国产青草久久久久福利| 亚洲一级Av无码毛片久久精品| 国产真实乱对白精彩久久| 青青草原1769久久免费播放| 97精品国产91久久久久久| 久久香蕉超碰97国产精品| 国产成年无码久久久免费| 97香蕉久久夜色精品国产 | 区久久AAA片69亚洲| 欧美久久天天综合香蕉伊| 久久久国产精品| 久久影视综合亚洲| 久久精品这里只有精99品| 久久综合色区| 久久久精品久久久久影院| 久久国语露脸国产精品电影|