• <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 閱讀(130) 評論(0)  編輯 收藏 引用
            久久久久久毛片免费播放| 久久成人小视频| 久久婷婷综合中文字幕| 国产精品嫩草影院久久| 热久久视久久精品18| 久久久噜噜噜www成人网| 色综合久久综精品| 久久久久亚洲AV无码观看 | 亚洲AV伊人久久青青草原| 精品久久久无码人妻中文字幕| 欧美精品久久久久久久自慰| 国产成人精品久久亚洲高清不卡| 免费精品国产日韩热久久| 国产成人精品久久| 久久精品无码一区二区无码| 国产成人精品白浆久久69| 欧美久久久久久午夜精品| 久久中文精品无码中文字幕| 久久香综合精品久久伊人| 青青草原综合久久大伊人导航| 久久久久亚洲av无码专区喷水 | 四虎国产精品免费久久久| 午夜肉伦伦影院久久精品免费看国产一区二区三区 | 人妻丰满?V无码久久不卡| 国产精品久久久福利| 老男人久久青草av高清| 久久国产成人亚洲精品影院 | 日日狠狠久久偷偷色综合免费 | 亚洲精品乱码久久久久久蜜桃| 久久精品一区二区国产| 国产亚洲色婷婷久久99精品| 亚洲欧洲日产国码无码久久99| 无码人妻少妇久久中文字幕| 国内精品久久久久久久影视麻豆| 久久精品国产亚洲AV无码娇色| 久久久www免费人成精品| 99久久综合国产精品免费| 亚洲国产一成久久精品国产成人综合| 狠狠人妻久久久久久综合蜜桃| 99久久精品无码一区二区毛片 | 99久久成人18免费网站|