• <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)  編輯 收藏 引用
            狠狠色丁香久久婷婷综合图片| 狠狠色丁香婷婷综合久久来| 亚洲人成无码网站久久99热国产| 国产精品熟女福利久久AV| 久久久久一级精品亚洲国产成人综合AV区 | 99国产欧美精品久久久蜜芽| AV狠狠色丁香婷婷综合久久 | 国产精品久久久久aaaa| 精品久久久久久久久久中文字幕 | 久久综合亚洲鲁鲁五月天| 97久久精品无码一区二区| 久久人妻少妇嫩草AV蜜桃| 中文字幕热久久久久久久| 狠狠精品久久久无码中文字幕| 2021国内久久精品| 精品免费久久久久国产一区| 天天躁日日躁狠狠久久| 免费观看久久精彩视频| 午夜欧美精品久久久久久久| 久久天天躁狠狠躁夜夜2020老熟妇| 精品久久久久香蕉网| 亚洲精品第一综合99久久| 久久久久亚洲精品天堂久久久久久| 2021久久精品国产99国产精品| 久久九九久精品国产免费直播| 国产精品无码久久综合网| 国产精品九九九久久九九| 久久久噜噜噜久久中文字幕色伊伊 | 久久妇女高潮几次MBA| 狠狠人妻久久久久久综合蜜桃| 丁香狠狠色婷婷久久综合| 久久久久久无码Av成人影院| 国产色综合久久无码有码| 亚洲欧洲久久av| 一本色道久久88综合日韩精品 | 久久99精品久久久久子伦| 久久午夜福利无码1000合集| 久久香综合精品久久伊人| 久久久久久久精品妇女99| 国内精品久久久久久久久电影网| 久久99国产精品久久99小说|