• <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)  編輯 收藏 引用
            久久久久久国产精品美女 | 区亚洲欧美一级久久精品亚洲精品成人网久久久久 | 久久久久亚洲AV片无码下载蜜桃| 亚洲AV无码一区东京热久久| 日本精品久久久久中文字幕8| 久久精品成人一区二区三区| 日韩久久久久中文字幕人妻| 久久久精品免费国产四虎| 日本精品久久久久影院日本| 熟妇人妻久久中文字幕| 国产精品免费看久久久香蕉| 丰满少妇高潮惨叫久久久| 中文字幕无码精品亚洲资源网久久 | 久久婷婷五月综合国产尤物app| 99久久婷婷国产综合精品草原| 久久国产精品99国产精| 久久se精品一区二区影院 | 亚洲国产成人久久一区WWW| 91精品国产综合久久婷婷| 亚洲∧v久久久无码精品| 久久青青草原精品国产软件| 国产一区二区三精品久久久无广告| 亚洲日韩中文无码久久| 色综合合久久天天给综看| 久久精品国产精品青草app| 久久99免费视频| 婷婷综合久久中文字幕蜜桃三电影| 国产免费福利体检区久久| 久久被窝电影亚洲爽爽爽| 久久Av无码精品人妻系列 | 久久免费视频观看| 国产精品久久久久久福利漫画| 无码人妻久久一区二区三区| 久久午夜福利无码1000合集| 久久综合视频网站| 久久久久久青草大香综合精品| 精品多毛少妇人妻AV免费久久| 99久久精品国产综合一区 | 日本精品久久久久中文字幕| 久久精品免费一区二区三区| 久久综合九色综合精品|