• <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 糯米 閱讀(474) 評論(0)  編輯 收藏 引用 所屬分類: POJ

            伊人久久免费视频| 伊人久久久AV老熟妇色| 久久线看观看精品香蕉国产| 久久91精品国产91久久麻豆| 国产激情久久久久影院小草 | 国产亚洲精品自在久久| 久久免费视频网站| 一级a性色生活片久久无| 一本久久a久久精品vr综合| 91久久精品无码一区二区毛片| 久久婷婷五月综合97色直播| 久久国产精品成人影院| 亚洲另类欧美综合久久图片区| 99久久人妻无码精品系列| 青青草国产97免久久费观看| 精品久久久久久中文字幕人妻最新| 国产日韩久久久精品影院首页| 久久午夜福利无码1000合集| 99久久精品免费| 国产成人精品免费久久久久| 久久婷婷五月综合成人D啪| 色综合久久精品中文字幕首页| 久久久久久国产精品美女| 91精品国产高清久久久久久国产嫩草| 久久天天躁夜夜躁狠狠| 久久青青国产| 国产69精品久久久久9999| 69SEX久久精品国产麻豆| 97久久国产综合精品女不卡| 久久久中文字幕日本| 岛国搬运www久久| 中文字幕成人精品久久不卡| 狠狠狠色丁香婷婷综合久久俺| 无码日韩人妻精品久久蜜桃 | 亚洲国产成人精品久久久国产成人一区二区三区综 | 99国产欧美精品久久久蜜芽| 99久久做夜夜爱天天做精品| 中文国产成人精品久久亚洲精品AⅤ无码精品| 久久久九九有精品国产| 伊人热人久久中文字幕| 国内精品久久久久久麻豆|