• <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 <iostream>
            #include 
            <vector>
            #include 
            <algorithm>

            using namespace std;

            struct Edge
            {
                
            int row;
                
            int column;
                
            int value;

                Edge()
                
            {}

                Edge( 
            int a, int b, int c )
                    :row(a),column(b),value(c)
                
            {}
            }
            ;

            bool operator<( Edge const& Itema, Edge const& Itemb )
            {
                
            return Itema.value> Itemb.value;
            }


            vector
            <Edge> graph;
            int          visite[2001];
            char         ch[2001][8];

            int find( int x )
            {
                
            if ( x!= visite[x] )
                    
            return find( visite[x] );

                
            return x;
            }


            int distance( char str1[8], char str2[8] )
            {
                
            int num= 0;

                
            for ( int i= 0; i< 8++i )
                    
            if ( str1[i]!= str2[i] )
                        num
            ++;

                
            return num;
            }


            int main()
            {
                
            int n;

                
            while ( scanf("%d",&n), n )
                
            {
                    
            for ( int i= 0; i< n; ++i )
                        scanf(
            "%s",ch[i] );

                    graph.reserve ( n
            + 1 );

                    
            for ( int i= 0; i< n; ++i )
                    
            {
                        
            for ( int j= 0; j< i; ++j )
                            graph.push_back (  Edge( j,i,distance( ch[i], ch[j] ) ) );
                
                        visite[i]
            = i;
                    }


                    make_heap( graph.begin (), graph.end () );
                    
            int sum= 0;
                    
            int num= 1;

                    
            while ( num< n )
                    
            {
                        
            int u,v;
                        
            if ( (u= find(graph[0].column))!= (v= find(graph[0].row ) ) )
                        
            {
                            sum
            += graph[0].value;
                            visite[v]
            = u;
                            num
            ++;
                        }


                        pop_heap( graph.begin (), graph.end () );
                        graph.pop_back ();
                    }


                    printf( 
            "The highest possible quality is 1/%d.\n", sum );

                    graph.clear ();
                }


                
            return 0;
            }
            posted on 2008-11-06 12:00 Darren 閱讀(234) 評論(3)  編輯 收藏 引用

            評論:
            # re: Pku 1789 Truck History 2008-11-06 12:42 | infinity
            這題好像就是一個最小生成樹吧!  回復  更多評論
              
            # re: Pku 1789 Truck History 2008-11-06 13:02 | Darren
            @infinity
            這是最小生成樹, 我用的是kruskal算法  回復  更多評論
              
            # re: Pku 1789 Truck History 2008-11-06 14:03 | ******
            我的做法:
            串兩兩比較,匹配他們,統計不同的字符數,然后就產生了一張抽象的權值圖
            然后prim  回復  更多評論
              
            伊人久久大香线焦AV综合影院| 无码精品久久久天天影视| 91精品国产高清91久久久久久| 久久人人妻人人爽人人爽| 99久久人妻无码精品系列蜜桃| 精品久久久久久久中文字幕| 午夜精品久久久久| 91精品国产高清久久久久久io| 久久久久久国产a免费观看不卡| 一本色综合久久| 国产精品VIDEOSSEX久久发布| 欧美久久久久久精选9999| 精品国产乱码久久久久久郑州公司 | 久久久久久久久久久精品尤物| 无码AV波多野结衣久久| 色偷偷888欧美精品久久久| 久久亚洲精品无码aⅴ大香| 久久亚洲精品中文字幕三区| 国产精品久久久久a影院| 国产免费福利体检区久久| 久久九九精品99国产精品| 亚洲国产成人精品91久久久 | 久久久噜噜噜久久熟女AA片 | 久久国产影院| 国产精品女同久久久久电影院| 亚洲国产精品狼友中文久久久| 久久免费国产精品一区二区| 久久精品99久久香蕉国产色戒 | 韩国三级中文字幕hd久久精品 | 久久不射电影网| 久久久久国产精品熟女影院 | 青青热久久综合网伊人| 久久66热人妻偷产精品9| 亚洲国产精品久久久天堂| 久久人人添人人爽添人人片牛牛 | 亚洲一区精品伊人久久伊人| 久久久91人妻无码精品蜜桃HD| 9999国产精品欧美久久久久久| 91精品国产91热久久久久福利| 久久国产亚洲精品无码| 2021久久国自产拍精品|