• <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)  編輯 收藏 引用
            久久精品国产亚洲αv忘忧草 | 久久这里有精品视频| 品成人欧美大片久久国产欧美| 久久国产精品久久国产精品| 亚洲一区中文字幕久久| 亚洲午夜福利精品久久| 久久午夜电影网| 日本人妻丰满熟妇久久久久久| 久久成人国产精品一区二区| 久久久久久无码Av成人影院| 亚洲午夜无码久久久久小说| 99久久国产精品免费一区二区 | 亚洲av伊人久久综合密臀性色| 国产成人综合久久久久久| 2021国内久久精品| 久久国产影院| 成人精品一区二区久久| 久久九九兔免费精品6| 91久久精品国产成人久久| 亚洲中文精品久久久久久不卡| 久久99免费视频| 久久久久亚洲精品天堂| 久久久一本精品99久久精品88| 久久―日本道色综合久久| 久久久久久精品无码人妻| 久久婷婷色综合一区二区| 一本大道久久a久久精品综合| 亚洲精品美女久久777777| 亚洲综合久久夜AV | 久久久久亚洲AV成人网| 2021少妇久久久久久久久久| 精品精品国产自在久久高清| 欧美日韩精品久久免费| 久久久久综合中文字幕 | 99久久国语露脸精品国产| 久久AV高潮AV无码AV| 久久久久久精品免费免费自慰| 久久只有这里有精品4| 精品国产日韩久久亚洲| 香港aa三级久久三级老师2021国产三级精品三级在 | 欧美亚洲国产精品久久蜜芽|