• <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 }
            国产精品久久久久久福利漫画 | 久久国产免费观看精品| 欧美色综合久久久久久| 国产AⅤ精品一区二区三区久久| 国产亚洲欧美精品久久久| 亚洲av伊人久久综合密臀性色 | 久久九九久精品国产| 精品久久久久久国产| 99久久99这里只有免费费精品| 伊人久久大香线蕉综合Av | 久久伊人色| 无码人妻久久一区二区三区蜜桃| 久久本道综合久久伊人| 久久亚洲中文字幕精品一区| 日日狠狠久久偷偷色综合96蜜桃| 国产成人综合久久精品尤物| 久久国产精品免费一区二区三区| 国产无套内射久久久国产| 精品久久久久久久久久久久久久久| 精品久久久久久无码免费| 久久成人国产精品一区二区| 一级做a爰片久久毛片免费陪| 久久国产AVJUST麻豆| 久久亚洲精品成人AV| 国产精品美女久久久久AV福利| 久久影院亚洲一区| 国产亚洲精品久久久久秋霞| 久久97精品久久久久久久不卡| 国产亚洲精午夜久久久久久| 超级碰碰碰碰97久久久久| 久久久久AV综合网成人| 久久99热这里只有精品国产| 无码AV波多野结衣久久| 久久99亚洲综合精品首页| 波多野结衣AV无码久久一区| 99久久婷婷国产一区二区| A级毛片无码久久精品免费| 伊人久久综合热线大杳蕉下载| 热久久最新网站获取| 色综合久久综精品| 亚洲色大成网站www久久九|