• <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>
            隨筆 - 19, 文章 - 0, 評(píng)論 - 2, 引用 - 0
            數(shù)據(jù)加載中……

            hdu1548_A strange lift

            #include <stdio.h>
            #define DEBUG 1
            const int N=300 ;
            const int Max = 10000000 ;
            int n, map[N][N], used[N], dis[N] ;

            void Dijkstra( int a, int b )
            {
                
            int i, j, index, min ;
                
            for( i=1; i<=n; ++i ){
                    dis[i] 
            = map[a][i] ;
                    used[i] 
            = 0 ;
                }

                used[a] 
            = 1 ;
                
            for( i=1; i<=n; ++i ){
                    index 
            = a ;
                    min 
            = Max ;
                    
            for( j=1; j<=n; ++j ){
                           
            if!used[j] && min > dis[j] ){
                               min 
            = dis[j] ;
                               index 
            = j ;
                         }

                    }

                    used[index] 
            = 1 ;
                    
            for( j=1; j<=n; ++j ){
                        
            if( dis[j] > dis[index]+map[index][j] )
                            dis[j] 
            = dis[index]+map[index][j] ;
                    }

                }

                
            if( dis[b] == Max ){
                    
            //printf("%d\n", dis[b] ) ;
                    printf("-1\n") ;
                }
                   
                
            else
                    printf(
            "%d\n", dis[b] ) ;
            }


            int main( )
            {
                
            #if DEBUG
                freopen(
            "C:\\Documents and Settings\\Administrator\\桌面\\in.in","r",stdin) ;
                freopen(
            "C:\\Documents and Settings\\Administrator\\桌面\\out.out","w",stdout) ;
                
            #endif
                
                
            int i, j, a, b, temp ;
                
            while( scanf("%d"&n) && n ){
                    
            for( i=1; i<=n; ++i ){
                           
            for( j=1; j<=n; ++j )
                               map[i][j] 
            = Max ;
                           map[i][i] 
            = 0 ;    
                    }

                    scanf(
            "%d%d"&a, &b ) ;
                    
            for( i=1; i<=n; ++i ){
                        scanf(
            "%d"&temp ) ;
                        
            if( i - temp > 0 )
                            map[i][i
            -temp] = 1 ;
                        
            if( i + temp <= n )
                             map[i][i
            +temp] = 1 ;
                    }

                    Dijkstra( a, b ) ;
                }
                     
                
            return 0 ;
            }

            posted on 2009-05-03 21:10 祝你好運(yùn)! 閱讀(186) 評(píng)論(0)  編輯 收藏 引用


            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


            久久人人爽人人爽人人片AV东京热 | 久久se精品一区二区| 欧美精品乱码99久久蜜桃| 四虎国产精品免费久久5151| 久久久久久九九99精品| 久久影院综合精品| 久久精品国产网红主播| 久久久无码精品亚洲日韩蜜臀浪潮| 亚洲精品高清一二区久久| 久久精品视频一| 国产亚洲美女精品久久久2020| 亚洲综合久久久| 成人午夜精品无码区久久| 久久99久久99精品免视看动漫 | 久久久久久久久久久免费精品| 国产精品丝袜久久久久久不卡| 久久国产福利免费| 午夜福利91久久福利| 久久久久久精品久久久久| 日韩AV无码久久一区二区| 99久久久国产精品免费无卡顿| 国产精品18久久久久久vr | 久久国产亚洲精品麻豆| 四虎国产永久免费久久| 久久精品国产亚洲一区二区三区| 久久精品亚洲乱码伦伦中文| 久久天天躁夜夜躁狠狠| 国产精品美女久久久久久2018| 久久电影网一区| 亚洲精品无码久久不卡| 久久亚洲精品中文字幕| 国产精品成人久久久久久久| 麻豆久久久9性大片| 韩国三级大全久久网站| 色婷婷久久综合中文久久一本| 久久99国产乱子伦精品免费| 久久夜色精品国产www| 国产69精品久久久久777| 亚洲午夜无码久久久久小说| 精品熟女少妇a∨免费久久| 中文字幕精品无码久久久久久3D日动漫|