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

            糯米

            TI DaVinci, gstreamer, ffmpeg
            隨筆 - 167, 文章 - 0, 評論 - 47, 引用 - 0
            數據加載中……

            POJ 3039 Skiing 單源最短路徑

            這題看起來很屌。
            但是實際上走到每個點之后,速度必然是當前點和左上角點的差值的倒數。
            所以,每個點到其他點的所花費的時間都是這個點自己的值決定的。
            而且沒可能經過一個點兩次的,因為經過兩次肯定是浪費時間的。
            問題就變成了求最短路徑。

            注意:
            這題的精度很莫名其妙,用C++可以AC的,G++、GCC都是WA。
            不能用整數來保存時間,雖然看上去位數是夠用的,但是遇到比較屌的數據就掛了。
            就在這個問題上杯具了很久。

            #include <stdio.h>
            #include 
            <math.h>

            #ifndef _countof
            #define _countof(x) (sizeof(x)/sizeof(x[0]))
            #endif

            #define SIZE 128

            int map[SIZE][SIZE], R, C, V;
            double D[SIZE][SIZE], _tbl[128], *tbl = &_tbl[64];
            int queue[65536][2], head, tail;
            int vis[SIZE][SIZE];

            inline 
            void push(int y, int x, double d)
            {
                
            if (y < 0 || y >= R || x < 0 || x >= C)
                    
            return ;
                
            if (d > D[y][x])
                    
            return ;
                D[y][x] 
            = d;
                
            if (vis[y][x])
                    
            return ;
                vis[y][x] 
            = 1;
                queue[tail][
            0= y;
                queue[tail][
            1= x;
                tail
            ++;
                tail 
            &= _countof(queue) - 1;
            }


            inline 
            void pop(int *y, int *x)
            {
                
            *= queue[head][0];
                
            *= queue[head][1];
                head
            ++;
                head 
            &= _countof(queue) - 1;
                vis[
            *y][*x] = 0;
            }


            int main()
            {
                
            int i, j;
                
            double d;

                freopen(
            "e:\\test\\in.txt""r", stdin);

                
            for (i = -64; i <= 64; i++)
                    tbl[i] 
            = pow(2.0, i);

                scanf(
            "%d%d%d"&V, &R, &C);
                
            for (i = 0; i < R; i++{
                    
            for (j = 0; j < C; j++{
                        scanf(
            "%d"&map[i][j]);
                        
            if (i || j)
                            map[i][j] 
            -= map[0][0];
                        D[i][j] 
            = 1e80;
                    }

                }

                map[
            0][0= 0;

                push(
            000); 
                
            while (head != tail) {
                    pop(
            &i, &j);
                    d 
            = D[i][j] + tbl[map[i][j]];
                    push(i 
            + 1, j, d);
                    push(i 
            - 1, j, d);
                    push(i, j 
            + 1, d);
                    push(i, j 
            - 1, d);
                }


                printf(
            "%.2lf\n", D[R - 1][C - 1/ V);
                
                
            return 0;
            }

            posted on 2010-04-12 16:45 糯米 閱讀(480) 評論(0)  編輯 收藏 引用 所屬分類: POJ

            久久免费高清视频| 狠狠色婷婷久久综合频道日韩| 7777久久亚洲中文字幕| 亚洲综合久久综合激情久久| 亚洲精品久久久www| 精品久久无码中文字幕| 要久久爱在线免费观看| AV无码久久久久不卡网站下载| 久久久久无码专区亚洲av| 99re久久精品国产首页2020| 亚洲精品无码久久久| 青青热久久综合网伊人| 中文字幕热久久久久久久| 欧美国产精品久久高清| 97精品伊人久久久大香线蕉 | 噜噜噜色噜噜噜久久| 2022年国产精品久久久久| 欧美激情一区二区久久久| 久久精品国产色蜜蜜麻豆| 久久青青草原亚洲av无码app| 久久这里都是精品| 久久久精品久久久久特色影视| 久久99国产精一区二区三区| 国产美女久久精品香蕉69| 老男人久久青草av高清| 亚洲精品国产自在久久| 香蕉久久永久视频| 久久免费99精品国产自在现线 | 国产午夜精品久久久久九九电影| 亚洲AV无码久久精品狠狠爱浪潮| 一本一本久久a久久精品综合麻豆| 四虎国产精品免费久久5151| 狠狠色婷婷综合天天久久丁香 | 精品综合久久久久久97| 久久国产亚洲精品| 久久无码国产专区精品| 无码国内精品久久人妻蜜桃| 一本久久a久久精品亚洲| 午夜人妻久久久久久久久| 国产精品久久久久9999| 狠狠精品久久久无码中文字幕|