• <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
            數(shù)據(jù)加載中……

            POJ 3039 Skiing 單源最短路徑

            這題看起來很屌。
            但是實(shí)際上走到每個(gè)點(diǎn)之后,速度必然是當(dāng)前點(diǎn)和左上角點(diǎn)的差值的倒數(shù)。
            所以,每個(gè)點(diǎn)到其他點(diǎn)的所花費(fèi)的時(shí)間都是這個(gè)點(diǎn)自己的值決定的。
            而且沒可能經(jīng)過一個(gè)點(diǎn)兩次的,因?yàn)榻?jīng)過兩次肯定是浪費(fèi)時(shí)間的。
            問題就變成了求最短路徑。

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

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

            久久久噜噜噜久久| 久久亚洲国产欧洲精品一| 久久亚洲国产精品五月天婷| 久久人人爽人人人人片av| 99久久中文字幕| 三级三级久久三级久久| 久久精品视频网| 色婷婷久久综合中文久久蜜桃av| 亚洲午夜久久影院| 久久无码高潮喷水| 国产精品狼人久久久久影院 | 波多野结衣久久一区二区| 久久国产欧美日韩精品| 亚洲人成无码久久电影网站| 久久精品嫩草影院| 2021精品国产综合久久| 国内精品伊人久久久久777| 国产99久久九九精品无码| 久久99精品久久久久久久久久| 久久天天日天天操综合伊人av| 亚洲午夜精品久久久久久人妖| 韩国免费A级毛片久久| 色欲综合久久躁天天躁蜜桃 | 久久久久久午夜成人影院| 亚洲综合久久夜AV | 精品无码人妻久久久久久| 人人狠狠综合久久亚洲婷婷| 久久久久久久综合日本亚洲| 久久人人爽人人爽人人片AV不 | 日韩人妻无码精品久久久不卡| 亚洲国产婷婷香蕉久久久久久| 久久精品无码免费不卡| 狠狠色综合网站久久久久久久| 青青国产成人久久91网| 久久国产高清字幕中文| 九九久久99综合一区二区| 国产美女久久久| 久久精品99无色码中文字幕| 久久久久黑人强伦姧人妻| 久久综合九色综合欧美就去吻 | 久久精品国产99国产精偷|