• <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) 評(píng)論(0)  編輯 收藏 引用

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


            久久亚洲中文字幕精品一区四| 亚洲AV无码久久精品狠狠爱浪潮| 久久久久九国产精品| 性欧美大战久久久久久久| 97精品国产97久久久久久免费| 成人免费网站久久久| 日韩人妻无码一区二区三区久久99| 欧美大香线蕉线伊人久久| 久久人人爽人爽人人爽av| 久久成人国产精品| 久久人搡人人玩人妻精品首页 | 国产成人精品综合久久久| 伊人久久五月天| 国产精品丝袜久久久久久不卡| 伊人久久精品无码av一区| 久久无码人妻精品一区二区三区| 99久久人妻无码精品系列蜜桃| 伊人久久成人成综合网222| 岛国搬运www久久| 久久久久久毛片免费播放| 久久人妻少妇嫩草AV蜜桃| 性做久久久久久久久| 久久伊人色| 久久久久成人精品无码| 国产精品热久久无码av| 91久久精品电影| 99久久精品国产毛片| 草草久久久无码国产专区| 久久99久久99小草精品免视看| 亚洲AV无码久久精品成人| 国产成人无码精品久久久性色 | 色综合久久久久网| 99久久国产热无码精品免费| 99久久人妻无码精品系列| 国产精品久久成人影院| 中文字幕成人精品久久不卡| 四虎国产精品免费久久5151| 狠狠色综合网站久久久久久久| 久久狠狠一本精品综合网| 久久亚洲av无码精品浪潮| 亚洲日本久久久午夜精品|