• <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)  編輯 收藏 引用
            日本欧美久久久久免费播放网| AA级片免费看视频久久| 久久久久久久久久久精品尤物| 伊人久久综合成人网| 久久久精品一区二区三区| 久久免费观看视频| 91精品国产乱码久久久久久| 色狠狠久久综合网| 久久99精品九九九久久婷婷| 久久精品国产亚洲av日韩| 色综合久久天天综线观看| 久久国产乱子精品免费女| 亚洲色大成网站WWW久久九九| 国产伊人久久| AA级片免费看视频久久| 国产午夜福利精品久久2021| 久久精品aⅴ无码中文字字幕不卡| 精品久久久久久无码中文字幕 | 久久久久人妻一区二区三区 | 国产成人精品综合久久久| 久久国产精品偷99| 97精品伊人久久久大香线蕉| 国产精品久久国产精麻豆99网站| 亚洲中文字幕无码久久2017| 久久人人爽人人爽人人片av麻烦| 日韩中文久久| 久久人妻少妇嫩草AV无码蜜桃| 国产精品久久久久乳精品爆| 成人亚洲欧美久久久久| 亚洲天堂久久精品| 久久99精品免费一区二区| 久久亚洲国产成人精品无码区| 久久精品18| 久久综合偷偷噜噜噜色| 久久中文字幕人妻丝袜| 午夜欧美精品久久久久久久| 久久亚洲精品成人AV| 久久精品国产99久久久| 久久久青草青青亚洲国产免观| 精品久久久久久无码免费| 亚洲va久久久久|