• <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>
            #include <cstdio>
            #include 
            <vector>
            #include 
            <bitset>
            #include 
            <queue>

            using namespace std;

            int abs( int a, int b )
            {
                
            return a> b? a- b: b- a;
            }

            struct Point
            {
                
            int x, y;
                Point(){}
                Point( 
            int a, int b ): x(a), y(b) {}
            };

            struct Node
            {
                
            int u, total;
                bitset
            <12> state;

                Node(){}
                Node( 
            int a, int b, bitset<12> c ): u(a), total(b), state(c) {}
            };

            int   r, c,result,n;
            vector
            <Point> map;
            bool visite[25][25];
            int  graph[15][15];

            void bfs()
            {
                queue
            <Node> q;
                bitset
            <12> t; t.reset ();

                q.push( Node( 
            00, t ) ); 

                
            while!q.empty() )
                {
                    
            int u= q.front().u, total= q.front().total;
                    bitset
            <12> state= q.front().state; q.pop();

                    
            bool ok= true;
                    
            forint i= 0; i<=  n; ++i )
                        
            if( state[i]== 0 ) ok= false;

                    
            if( ok  )
                    {
                        
            if( total+ graph[u][0]< result ) result= total+ graph[u][0];

                        
            continue;
                    }

                    
            forint i= 0; i<= n; ++i )
                    {
                        bitset
            <12> t= state;

                        
            if( t[i]== 0 && total+ graph[u][i]< result )
                        {
                            t[i]
            = 1;

                            q.push( Node( i, total
            + graph[u][i], t ) );
                        }
                    }
                }
            }

            int main()
            {
                
            int test;
                scanf(
            "%d",&test);

                
            while( test-- )
                {
                    map.clear();
                    scanf(
            "%d%d",&r,&c);

                    
            int a,b;
                    scanf(
            "%d%d",&a,&b);  map.push_back( Point( a, b ) );

                    scanf(
            "%d",&n );
                    
            forint i= 0; i< n; ++i )
                    {
                        scanf(
            "%d%d",&a,&b);

                        map.push_back( Point(a,b) );
                    }

                    
            for( size_t i= 0; i< map.size(); ++i )
                        
            for( size_t j= 0; j< map.size(); ++j )
                            graph[i][j]
            = abs( map[i].x- map[j].x )+ abs( map[i].y- map[j].y );

                    result
            = 1<<30;

                    bfs();
                    printf(
            "The shortest path has length %d\n", result );
                }

                
            return 0;
            }

            posted on 2008-12-24 20:22 Darren 閱讀(131) 評論(0)  編輯 收藏 引用

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


            久久亚洲精品无码aⅴ大香| 99久久精品国产一区二区| 久久99精品国产麻豆宅宅| 精品国产乱码久久久久久1区2区| 国产精品久久久久AV福利动漫| 久久99免费视频| 久久亚洲精品无码VA大香大香| 久久99精品国产麻豆| 久久免费99精品国产自在现线| 久久精品国产99国产精品亚洲 | 久久成人国产精品一区二区| 久久久午夜精品| 久久香蕉一级毛片| 性做久久久久久久久久久| 久久精品国产亚洲AV无码麻豆| 久久99精品国产麻豆不卡| 久久久久亚洲精品天堂| 国内精品欧美久久精品| 久久水蜜桃亚洲av无码精品麻豆| 人妻系列无码专区久久五月天| 狠狠色丁香久久婷婷综合五月| 2021国产精品午夜久久| 污污内射久久一区二区欧美日韩| 国产亚洲美女精品久久久久狼| 国内精品久久久久影院亚洲| 久久99精品久久久久久秒播| 国产69精品久久久久777| 97精品伊人久久久大香线蕉| 久久精品国产只有精品66| 中文字幕亚洲综合久久| 国内精品伊人久久久久av一坑| 亚洲精品白浆高清久久久久久 | 欧美精品福利视频一区二区三区久久久精品 | 亚洲欧美日韩久久精品| 91久久精品视频| 精品午夜久久福利大片| 久久66热人妻偷产精品9| 99精品久久久久中文字幕| 久久er热视频在这里精品| 久久99热精品| 久久免费观看视频|