• <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
               :: 首頁 :: 新隨筆 ::  :: 聚合  :: 管理

            URAL1029

            Posted on 2008-10-31 15:25 Hero 閱讀(193) 評論(0)  編輯 收藏 引用 所屬分類: 代碼如詩--ACM
              1 // 1029 C++ Accepted 0.031 1 205 KB URAL
              2 
              3 //太假了--不想多說什么了
              4 
              5 #include <stdio.h>
              6 #include <stdlib.h>
              7 #include <string.h>
              8 
              9 const int INF = 1000000000 ;
             10 
             11 int data[110][550] ;
             12 int dp[110][550] ;
             13 
             14 struct PATH
             15 {
             16     int x ;
             17     int y ;
             18 };
             19 struct PATH path[110][550] ;
             20 struct PATH que[110*550] ;
             21 int head, tail ;
             22 
             23 int inn, inm ;
             24 
             25 void path_in_que( int floor, int posi )
             26 {
             27     if1 == floor )
             28     {
             29         que[++head].x = floor ; que[head].y = posi ;
             30     }
             31     else
             32     {
             33         path_in_que( path[floor][posi].x, path[floor][posi].y ) ;
             34         que[++head].x = floor ; que[head].y = posi ;
             35     }
             36 }
             37 
             38 int main()
             39 {
             40     scanf( "%d %d"&inn, &inm ) ;
             41     forint i=1; i<=inn; i++ )
             42     {
             43         forint j=1; j<=inm; j++ )
             44         {
             45             scanf( "%d"&data[i][j] ) ;
             46         }
             47     }//data input
             48 
             49     forint i=1; i<=inm; i++ )
             50     {
             51         dp[1][i] = data[1][i] ;
             52         path[1][i].x = 1 ; path[1][i].y = i ;
             53     }
             54     forint i=2; i<=inn; i++ )
             55     {
             56         forint j=1; j<=inm; j++ )
             57         {
             58             dp[i][j] = dp[i-1][j] + data[i][j] ;
             59             path[i][j].x = i-1 ; path[i][j].y = j ;
             60         }
             61         int cnt = 1 ;
             62         while( cnt != 0 )
             63         {
             64             cnt = 0 ;
             65             forint j=2; j<=inm; j++ )
             66             {
             67                 if( dp[i][j] > dp[i][j-1]+data[i][j] )
             68                 {
             69                     dp[i][j] = dp[i][j-1+ data[i][j] ;
             70                     path[i][j].x = i ; path[i][j].y = j-1 ;
             71                     cnt ++ ;
             72                 }
             73             }
             74             forint j=inm-1; j>=1; j-- )
             75             {
             76                 if( dp[i][j] > dp[i][j+1]+data[i][j] )
             77                 {
             78                     dp[i][j] = dp[i][j+1+ data[i][j] ;
             79                     path[i][j].x = i ; path[i][j].y = j+1 ;
             80                     cnt ++ ;
             81                 }
             82             }
             83         }
             84     }//dp
             85 
             86     int minval = INF ; int minposi ;
             87     forint i=1; i<=inm; i++ )
             88     {
             89         if( minval >= dp[inn][i] ) { minval = dp[inn][i] ; minposi = i ; }
             90     }
             91 
             92     head = tail = 0 ;
             93     //path_in_que( inn, minposi ) ;
             94 
             95     que[++head].x = inn, que[head].y = minposi ;
             96     int lastx = inn ;
             97     int lasty = minposi ;
             98     whiletrue )
             99     {
            100         int tempx = lastx ; int tempy = lasty ;
            101         if( lastx==path[tempx][tempy].x && lasty==path[tempx][tempy].y ) break ;
            102         lastx = path[tempx][tempy].x ; lasty = path[tempx][tempy].y ;
            103         que[++head].x = lastx ; que[head].y = lasty ;
            104     }
            105     for( tail=head; tail>=1; tail-- )
            106     {
            107         //if( que[tail].x == inn ) break ;
            108         printf( "%d ", que[tail].y ) ;
            109     }
            110     printf( "\n" ) ;
            111     //printf( "%d\n", que[tail].y ) ;
            112 /*
            113     char *blank = "" ; tail = 1 ;
            114     for( tail=1; tail<=head; tail++ )
            115     {
            116         if( que[tail].x == inn ) break ;
            117         printf( "%d ", que[tail].y ) ;
            118     }
            119     printf( "%d\n", que[tail].y ) ;
            120 */
            121     return 0 ;
            122 }
            色欲综合久久躁天天躁蜜桃| 色噜噜狠狠先锋影音久久| 中文字幕精品无码久久久久久3D日动漫| 丁香久久婷婷国产午夜视频| 久久久久亚洲av成人无码电影 | 午夜精品久久久久久久无码| 久久笫一福利免费导航| 久久精品麻豆日日躁夜夜躁| 亚洲一本综合久久| 热re99久久精品国99热| 国产精品xxxx国产喷水亚洲国产精品无码久久一区 | 伊人久久大香线蕉综合网站| 色婷婷综合久久久久中文| 国产成人无码精品久久久免费| 久久久久久精品无码人妻| av无码久久久久不卡免费网站 | 精品999久久久久久中文字幕| 欧美亚洲日本久久精品| 久久香蕉综合色一综合色88| 99精品国产综合久久久久五月天| 精品无码久久久久久尤物| 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 | 狠狠综合久久综合88亚洲| 国产A级毛片久久久精品毛片| 国内精品伊人久久久久777| 久久久久国产一级毛片高清板 | 2021最新久久久视精品爱| 蜜桃麻豆www久久| 99久久精品国产免看国产一区| 国产69精品久久久久观看软件| 久久精品国产欧美日韩| 久久亚洲国产欧洲精品一| 国产精品毛片久久久久久久 | 97久久久精品综合88久久| 久久人人青草97香蕉| 一本色道久久88综合日韩精品 | 国产精品一区二区久久不卡| 亚洲AV无码久久| 日日噜噜夜夜狠狠久久丁香五月 | 香蕉久久夜色精品国产2020 | 久久精品女人天堂AV麻|