锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲国产精品国自产拍av秋霞,老色批av在线精品,久久精品国产免费http://m.shnenglu.com/MiYu/category/14522.html ______________鐧界櫧銇眿zh-cnMon, 18 Oct 2010 04:51:30 GMTMon, 18 Oct 2010 04:51:30 GMT60PKU 1258 POJ 1258Agri-Net ( MST Kruskarl 騫舵煡闆?) ACM 1258 IN PKUhttp://m.shnenglu.com/MiYu/archive/2010/10/16/130139.htmlMiYuMiYuSat, 16 Oct 2010 08:30:00 GMThttp://m.shnenglu.com/MiYu/archive/2010/10/16/130139.htmlhttp://m.shnenglu.com/MiYu/comments/130139.htmlhttp://m.shnenglu.com/MiYu/archive/2010/10/16/130139.html#Feedback0http://m.shnenglu.com/MiYu/comments/commentRss/130139.htmlhttp://m.shnenglu.com/MiYu/services/trackbacks/130139.htmlMiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?nbsp;______________鐧界櫧銇眿    

 

棰樼洰鍦板潃:

http://poj.org/problem?id=1258

棰樼洰鎻忚堪:

Agri-Net
Time Limit: 1000MSMemory Limit: 10000K
Total Submissions: 16557Accepted: 6745

Description

Farmer John has been elected mayor of his town! One of his campaign promises was to bring internet connectivity to all farms in the area. He needs your help, of course. 
Farmer John ordered a high speed connection for his farm and is going to share his connectivity with the other farmers. To minimize cost, he wants to lay the minimum amount of optical fiber to connect his farm to all the other farms. 
Given a list of how much fiber it takes to connect each pair of farms, you must find the minimum amount of fiber needed to connect them all together. Each farm must connect to some other farm such that a packet can flow from any one farm to any other farm. 
The distance between any two farms will not exceed 100,000. 

Input

The input includes several cases. For each case, the first line contains the number of farms, N (3 <= N <= 100). The following lines contain the N x N conectivity matrix, where each element shows the distance from on farm to another. Logically, they are N lines of N space-separated integers. Physically, they are limited in length to 80 characters, so some lines continue onto others. Of course, the diagonal will be 0, since the distance from farm i to itself is not interesting for this problem.

Output

For each case, output a single integer length that is the sum of the minimum length of fiber required to connect the entire set of farms.

Sample Input

4
0 4 9 21
4 0 8 17
9 8 0 16
21 17 16 0

Sample Output

28

棰樼洰鍒嗘瀽 :
 	MST 姘撮, 鐢↘RUSKARL 鎴?PRIM 杞繪澗鑳借繃.
浠g爜濡備笅 :
/*
Mail to   : miyubai@gamil.com
MyBlog    : http://baiyun.me
Link      : http://www.cnblogs.com/MiYu  || http://m.shnenglu.com/MiYu
Author By : MiYu
Test      : 1
Complier  : g++ mingw32-3.4.2
Program   : Agri-Net
Doc Name  : PKU_1258
*/
//#pragma warning( disable:4789 )
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <utility>
#include <queue>
#include <stack>
#include <list>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;
const int MAX = 105;
int st[105];
int N, x, y, w;
struct vv {
       int x, y, val;
       void set ( int a, int b, int w ) { x=a,y=b,val=w; }

}v[10005];       
bool cmp ( const vv &a, const vv &b ) {
          return a.val < b.val;     
}
void creat () {
     for ( int i = 0; i <= N; ++ i )
          st[i] = i;     
}
int find ( int x ) {
    return x != st[x] ? find ( st[x] ) : x;    
}
void merge ( int x, int y ) {
     x = find ( x );
     y = find ( y );
     if ( x == y ) return;
     st[y] = x;     
}
int main ()
{
    while ( scanf ( "%d", &N )==1) {
           creat ();
           memset ( v, 0, sizeof ( v ) );
           int c = 0;
           for ( int i = 1; i <= N; ++ i ) {
                for ( int j = 1; j <= N; ++ j ) {
                     scanf ( "%d", &w );  
                     v[c++].set ( i,j,w );  
                }    
           }     
           sort ( v, v + c, cmp );
           int sum = 0;
           for ( int i = 0 ; i < c; ++ i ) {
                if ( find ( v[i].x ) != find ( v[i].y ) ) {
                    sum += v[i].val;  
                    merge ( v[i].x, v[i].y );
                }    
           }
           printf ( "%d\n", sum );
    }
    return 0;
}

 



MiYu 2010-10-16 16:30 鍙戣〃璇勮
]]>
HDOJ 1879 HDU 1879 緇х畫鐣呴氬伐紼?ACM 1879 IN HDU http://m.shnenglu.com/MiYu/archive/2010/08/10/122965.htmlMiYuMiYuTue, 10 Aug 2010 11:23:00 GMThttp://m.shnenglu.com/MiYu/archive/2010/08/10/122965.htmlhttp://m.shnenglu.com/MiYu/comments/122965.htmlhttp://m.shnenglu.com/MiYu/archive/2010/08/10/122965.html#Feedback0http://m.shnenglu.com/MiYu/comments/commentRss/122965.htmlhttp://m.shnenglu.com/MiYu/services/trackbacks/122965.htmlMiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?______________鐧界櫧銇眿

棰樼洰鍦板潃:
         http://acm.hdu.edu.cn/showproblem.php?pid=1879
棰樼洰鎻忚堪:
緇х畫鐣呴氬伐紼?br>
Time Limit: 
2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 
4134    Accepted Submission(s): 1602


Problem Description
鐪佹斂搴?#8220;鐣呴氬伐紼?#8221;鐨勭洰鏍囨槸浣垮叏鐪佷換浣曚袱涓潙搴勯棿閮藉彲浠ュ疄鐜板叕璺氦閫氾紙浣嗕笉涓瀹氭湁鐩存帴鐨勫叕璺浉榪烇紝鍙鑳介棿鎺ラ氳繃鍏礬鍙揪鍗沖彲錛夈傜幇寰楀埌鍩庨晣閬撹礬緇熻琛紝琛ㄤ腑鍒楀嚭浜嗕換鎰忎袱鍩庨晣闂翠慨寤洪亾璺殑璐圭敤錛屼互鍙婅閬撹礬鏄惁宸茬粡淇氱殑鐘舵併傜幇璇蜂綘緙栧啓紼嬪簭錛岃綆楀嚭鍏ㄧ渷鐣呴氶渶瑕佺殑鏈浣庢垚鏈?br> 

Input
嫻嬭瘯杈撳叆鍖呭惈鑻ュ共嫻嬭瘯鐢ㄤ緥銆傛瘡涓祴璇曠敤渚嬬殑絎?琛岀粰鍑烘潙搴勬暟鐩甆 ( 
1< N < 100 )錛涢殢鍚庣殑 N(N-1)/2 琛屽搴旀潙搴勯棿閬撹礬鐨勬垚鏈強淇緩鐘舵侊紝姣忚緇?涓鏁存暟錛屽垎鍒槸涓や釜鏉戝簞鐨勭紪鍙鳳紙浠?緙栧彿鍒癗錛夛紝姝や袱鏉戝簞闂撮亾璺殑鎴愭湰錛屼互鍙婁慨寤虹姸鎬侊細(xì)1琛ㄧず宸插緩錛?琛ㄧず鏈緩銆?br>
褰揘涓?鏃惰緭鍏ョ粨鏉熴?br> 

Output
姣忎釜嫻嬭瘯鐢ㄤ緥鐨勮緭鍑哄崰涓琛岋紝杈撳嚭鍏ㄧ渷鐣呴氶渶瑕佺殑鏈浣庢垚鏈?br> 

Sample Input
3
1 2 1 0
1 3 2 0
2 3 4 0
3
1 2 1 0
1 3 2 0
2 3 4 1
3
1 2 1 0
1 3 2 1
2 3 4 1
0
 

Sample Output
3
1
0

棰樼洰鍒嗘瀽:
榪欓亾棰樺嚑涔庢槸鍜?HDU1233 <---璇︽儏璇風(fēng)偣鍑?   
鍑犱箮涓妯′竴鏍? 鍞竴涓嶅悓鐨勬槸: 鍦ㄤ竴浜涙潙搴勪箣闂村凡緇忔湁璺瓨鍦ㄤ簡!!!!
榪欏緢濂藉姙. 鎴戜滑鍙渶瑕佸湪杈撳叆鐨勬椂鍊欐妸宸茬粡瀛樺湪鐨勮礬鎻愬墠鍔犲叆騫舵煡闆嗗氨琛屼簡.
鎺ヤ笅鏉ョ殑灝?鏄?MST 浜?..........

浠g爜濡備笅:
MiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?______________鐧界櫧銇眿

#include 
<iostream>
#include 
<algorithm>
using namespace std;
typedef 
struct {
     
int parent;
     
int height;   
}Tset;  

typedef 
struct treeUFS{
       
public:
              treeUFS(
int n = 0):N(n+1) { set = new Tset[N];
                                          visited 
= new bool[N]; 
                                          
for ( int i = 0; i != N; ++ i) 
                                          
set[i].parent = i,set[i].height = 1,visited[i] = false
                                        }
              
~treeUFS(){ delete [] set; };
              
int find ( int x ){  int r = x;  while ( r != set[r].parent ) r = set[r].parent;
                                   
return r;
                                }
              
void setVisit ( int x, int y ) { visited[x] = visited[y] = true; } 
              
bool getVisit ( int x ) { return visited[x]; }
              
void Merge( int x,int y ){  x = find ( x );  y = find ( y );  
                                           
if ( x == y ) return;
                                           
if ( set[x].height == set[y].height ){
                                                
set[y].parent = x;
                                                
set[x].height ++;
                                           }
                                           
else if ( set[x].height < set[y].height ) {
                                                     
set[x].parent = y;       
                                                   }
                                           
else{   set[y].parent = x;
                                               }
                                        }
       
private:
              Tset 
*set;
              
bool *visited;
              
int N;         
}treeUFS; 
typedef 
struct edge {
       
int v1,v2;
       
int wei; 
       
int isBuild;    
}EDGE;
EDGE edge[
5005];
bool cmp ( EDGE A, EDGE B )
{
     
return A.wei < B.wei; 
}
int main ()
{
    
int N;
    
while ( scanf ( "%d",&N ) , N )
    {
            
int n = N * ( N - 1 ) / 2;     
            
int v1,v2,b;
            memset ( edge, 
0 , sizeof ( edge ) );
            treeUFS UFS ( N ); 
            
for ( int i = 1; i <= n; ++ i ) 
            {
                  scanf ( 
"%d%d"&edge[i].v1,&edge[i].v2 );
                  scanf ( 
"%d%d"&edge[i].wei,&edge[i].isBuild );
                  
if ( edge[i].isBuild == 1 )
                  {
                       UFS.Merge ( edge[i].v1, edge[i].v2 );
                       UFS.setVisit ( edge[i].v1, edge[i].v2 );
                  }
            } 
            sort ( edge 
+ 1, edge + n + 1, cmp );
            
int sum = 0;
            
for ( int i = 1; i <= n; ++ i )
            {
                  
if ( ( !UFS.getVisit(edge[i].v1) || !UFS.getVisit(edge[i].v2) ) || UFS.find(edge[i].v1) != UFS.find(edge[i].v2) )
                  {
                        UFS.setVisit ( edge[i].v1, edge[i].v2 );
                        UFS.Merge ( edge[i].v1, edge[i].v2 );
                        sum 
+= edge[i].wei;
                  }        
            }
            printf ( 
"%d\n",sum );
    }
    
return 0
}


MiYu 2010-08-10 19:23 鍙戣〃璇勮
]]>
HDOJ 1875 HDU 1875 鐣呴氬伐紼嬪啀緇?ACM 1875 IN HDU http://m.shnenglu.com/MiYu/archive/2010/08/10/122964.htmlMiYuMiYuTue, 10 Aug 2010 11:11:00 GMThttp://m.shnenglu.com/MiYu/archive/2010/08/10/122964.htmlhttp://m.shnenglu.com/MiYu/comments/122964.htmlhttp://m.shnenglu.com/MiYu/archive/2010/08/10/122964.html#Feedback0http://m.shnenglu.com/MiYu/comments/commentRss/122964.htmlhttp://m.shnenglu.com/MiYu/services/trackbacks/122964.htmlMiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?______________鐧界櫧銇眿

棰樼洰鍦板潃:
         http://acm.hdu.edu.cn/showproblem.php?pid=1875
棰樼洰鎻忚堪:
鐣呴氬伐紼嬪啀緇?br>
Time Limit: 
2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 
3822    Accepted Submission(s): 1076


Problem Description
鐩鎬俊澶у閮藉惉璇翠竴涓?#8220;鐧懼矝婀?#8221;鐨勫湴鏂瑰惂錛岀櫨宀涙箹鐨勫眳姘戠敓媧誨湪涓嶅悓鐨勫皬宀涗腑錛屽綋浠栦滑鎯沖幓鍏朵粬鐨勫皬宀涙椂閮借閫氳繃鍒掑皬鑸規(guī)潵瀹炵幇銆傜幇鍦ㄦ斂搴滃喅瀹氬ぇ鍔涘彂灞曠櫨宀涙箹錛屽彂灞曢鍏堣瑙e喅鐨勯棶棰樺綋鐒舵槸浜ら氶棶棰橈紝鏀垮簻鍐沖畾瀹炵幇鐧懼矝婀栫殑鍏ㄧ晠閫氾紒緇忚繃鑰冨療灝忕粍RPRush瀵圭櫨宀涙箹鐨勬儏鍐靛厖鍒嗕簡瑙e悗錛屽喅瀹氬湪絎﹀悎鏉′歡鐨勫皬宀涢棿寤轟笂妗ワ紝鎵璋撶鍚堟潯浠訛紝灝辨槸2涓皬宀涗箣闂寸殑璺濈涓嶈兘灝忎簬10綾籌紝涔熶笉鑳藉ぇ浜?000綾熾傚綋鐒訛紝涓轟簡鑺傜渷璧勯噾錛屽彧瑕佹眰瀹炵幇浠繪剰2涓皬宀涗箣闂存湁璺氬嵆鍙傚叾涓ˉ鐨勪環(huán)鏍間負(fù) 100鍏?/span>/綾熾?br> 

Input
杈撳叆鍖呮嫭澶氱粍鏁版嵁銆傝緭鍏ラ鍏堝寘鎷竴涓暣鏁癟(T 
<= 200)錛屼唬琛ㄦ湁T緇勬暟鎹?br>姣忕粍鏁版嵁棣栧厛鏄竴涓暣鏁癈(C <= 100),浠h〃灝忓矝鐨勪釜鏁幫紝鎺ヤ笅鏉ユ槸C緇勫潗鏍囷紝浠h〃姣忎釜灝忓矝鐨勫潗鏍囷紝榪欎簺鍧愭爣閮芥槸 0 <= x, y <= 1000鐨勬暣鏁般?br> 

Output
姣忕粍杈撳叆鏁版嵁杈撳嚭涓琛岋紝浠h〃寤烘ˉ鐨勬渶灝忚姳璐癸紝緇撴灉淇濈暀涓浣嶅皬鏁般傚鏋滄棤娉曞疄鐜板伐紼嬩互杈懼埌鍏ㄩ儴鐣呴氾紝杈撳嚭”oh
!”.
 

Sample Input
2
2
10 10
20 20
3
1 1
2 2
1000 1000
 

Sample Output
1414.2
oh
!

棰樼洰鍒嗘瀽:
鍥犱負(fù)杈規(guī)病鏈夌洿鎺ョ粰鍑? 鑰屾槸緇欑殑鍧愭爣鐐? 鎵浠ラ渶瑕佸厛璁$畻 姣忎竴涓偣鍒板叾浠栦換鎰忎竴鐐圭殑璺濈, 騫朵笖璁板綍涓嬫潵.  濡備笅 :
      for ( int i = 1; i <= N; ++ i )
           {
                 for ( int j = 1; j < i; ++ j )
                 {
                       edge[n].v1 = i;
                       edge[n].v2 = j;
                       edge[n].len = sqrt ( 0.0 + POW (LD[i].x - LD[j].x) + POW ( LD[i].y - LD[j].y ) );
                       n ++;
                 }
           }
娉ㄦ剰綰㈣壊閮ㄥ垎!!  榪欐牱鍋氬緢瀹夊叏, 涓嶅姞鐨勮瘽, G++鍙互閫氳繃,浣嗗湪C++涓婁細(xì)鍑虹幇緙栬瘧闂, 鍝ユ?zhèn)插墽浜?嬈?CE   T .T.

灝嗚竟璁板綍濂戒互鍚? 灝辨槸姝e畻鐨?鏈灝忕敓鎴愭爲(wèi)闂浜?........鐩存帴KRUSKAL浜? 榪欎釜鎴戞瘮杈冪啛涔? 鍛靛懙.

浠g爜濡備笅:
MiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?______________鐧界櫧銇眿


#include 
<iostream>
#include 
<algorithm>
#include 
<cmath>
#define POW(x) ( (x) * (x) )
using namespace std;
typedef 
struct {
     
int parent;
     
int height;   
}Tset;  
typedef 
struct treeUFS{
       
public:
              treeUFS(
int n = 0):N(n+1) { set = new Tset[N];
                                          visited 
= new bool[N]; 
                                          
for ( int i = 0; i != N; ++ i) 
                                          
set[i].parent = i,set[i].height = 1,visited[i] = false
                                        }
              
~treeUFS(){ delete [] set; };
              
int find ( int x ){  int r = x;  while ( r != set[r].parent ) r = set[r].parent;
                                   
return r;
                                }
              
void setVisit ( int x, int y ) { visited[x] = visited[y] = true; } 
              
bool getVisit ( int x ) { return visited[x]; }
              
void Merge( int x,int y ){  x = find ( x );  y = find ( y );  
                                           
if ( x == y ) return;
                                           
if ( set[x].height == set[y].height ){
                                                
set[y].parent = x;
                                                
set[x].height ++;
                                           }
                                           
else if ( set[x].height < set[y].height ) {
                                                     
set[x].parent = y;       
                                                   }
                                           
else{   set[y].parent = x;
                                               }
                                        }
              
int getTreeCount (){ int nCount = 0for ( int i = 1; i < N; ++ i ){
                                                         
if ( find (i) == i ){
                                                              nCount 
++
                                                         }
                                                   }
                                   
return nCount;
                                 }
       
private:
              Tset 
*set;
              
bool *visited;
              
int N;         
}treeUFS; 
struct island{
       
int x,y;
}LD[
105];
typedef 
struct edge{
       
int v1,v2;
       
double len;
}EDGE;
EDGE edge[
5050];
bool cmp ( EDGE A, EDGE B )
{
     
return A.len < B.len; 
}
int main ()
{
    
int T;
    scanf ( 
"%d",&T );
    
while ( T -- )
    {
           
int N;
           scanf ( 
"%d",&N );
           treeUFS UFS ( N );
           
for ( int i = 1; i <= N; ++ i )
           {
                 
int x,y;
                 scanf ( 
"%d%d",&LD[i].x,&LD[i].y );
           } 
           
int n = 1;
           
for ( int i = 1; i <= N; ++ i )
           {
                 
for ( int j = 1; j < i; ++ j )
                 {
                       edge[n].v1 
= i;
                       edge[n].v2 
= j;
                       edge[n].len 
= sqrt ( 0.0 + POW (LD[i].x - LD[j].x) + POW ( LD[i].y - LD[j].y ) ); 
                       n 
++;
                 }
           }
           
double sum = 0.0;
           n 
= N * ( N - 1 ) / 2;
           sort ( edge 
+ 1, edge + n + 1 , cmp );
           
for ( int i = 1; i <= n; ++ i )
           {
                 
if ( ( ( !UFS.getVisit(edge[i].v1) || !UFS.getVisit(edge[i].v2) ) || UFS.find(edge[i].v1) != UFS.find(edge[i].v2) ) && edge[i].len >=10 && edge[i].len <= 1000 ) 
                 {
                        UFS.setVisit ( edge[i].v1, edge[i].v2 );
                        UFS.Merge ( edge[i].v1, edge[i].v2 );
                        sum 
+= edge[i].len; 
                 }
           }
           
int tCount = UFS.getTreeCount();
           
if ( tCount != 1 )
           {
                 puts ( 
"oh!" );
                 
continue
           }
           printf ( 
"%.1lf\n",sum * 100 );
    }
    
return 0
}


MiYu 2010-08-10 19:11 鍙戣〃璇勮
]]>
HDOJ 1233 HDU 1233 榪樻槸鐣呴氬伐紼?ACM 1233 IN HDU http://m.shnenglu.com/MiYu/archive/2010/08/10/122956.htmlMiYuMiYuTue, 10 Aug 2010 09:47:00 GMThttp://m.shnenglu.com/MiYu/archive/2010/08/10/122956.htmlhttp://m.shnenglu.com/MiYu/comments/122956.htmlhttp://m.shnenglu.com/MiYu/archive/2010/08/10/122956.html#Feedback0http://m.shnenglu.com/MiYu/comments/commentRss/122956.htmlhttp://m.shnenglu.com/MiYu/services/trackbacks/122956.htmlMiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?______________鐧界櫧銇眿

棰樼洰鍦板潃:
         http://acm.hdu.edu.cn/showproblem.php?pid=1233
棰樼洰鎻忚堪:
榪樻槸鐣呴氬伐紼?br>
Time Limit: 
4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 
6742    Accepted Submission(s): 3087


Problem Description
鏌愮渷璋冩煡涔℃潙浜ら氱姸鍐碉紝寰楀埌鐨勭粺璁¤〃涓垪鍑轟簡浠繪剰涓ゆ潙搴勯棿鐨勮窛紱匯傜渷鏀垮簻“鐣呴氬伐紼?#8221;鐨勭洰鏍囨槸浣垮叏鐪佷換浣曚袱涓潙搴勯棿閮藉彲浠ュ疄鐜板叕璺氦閫氾紙浣嗕笉涓瀹氭湁鐩存帴鐨勫叕璺浉榪烇紝鍙鑳介棿鎺ラ氳繃鍏礬鍙揪鍗沖彲錛夛紝騫惰姹傞摵璁劇殑鍏礬鎬婚暱搴︿負(fù)鏈灝忋傝璁$畻鏈灝忕殑鍏礬鎬婚暱搴︺?br> 

Input
嫻嬭瘯杈撳叆鍖呭惈鑻ュ共嫻嬭瘯鐢ㄤ緥銆傛瘡涓祴璇曠敤渚嬬殑絎?琛岀粰鍑烘潙搴勬暟鐩甆 ( 
< 100 )錛涢殢鍚庣殑N(N-1)/2琛屽搴旀潙搴勯棿鐨勮窛紱伙紝姣忚緇欏嚭涓瀵規(guī)鏁存暟錛屽垎鍒槸涓や釜鏉戝簞鐨勭紪鍙鳳紝浠ュ強姝や袱鏉戝簞闂寸殑璺濈銆備負(fù)綆鍗曡搗瑙侊紝鏉戝簞浠?鍒癗緙栧彿銆?br>褰揘涓?鏃訛紝杈撳叆緇撴潫錛岃鐢ㄤ緥涓嶈澶勭悊銆?br> 

Output
瀵規(guī)瘡涓祴璇曠敤渚嬶紝鍦?琛岄噷杈撳嚭鏈灝忕殑鍏礬鎬婚暱搴︺?br> 

Sample Input
3
1 2 1
1 3 2
2 3 4
4
1 2 1
1 3 4
1 4 1
2 3 3
2 4 2
3 4 5
0
 

Sample Output
3
5

棰樼洰鍒嗘瀽:
鏈灝忕敓鎴愭爲(wèi)鐨勯棶棰?  --->  鐢?prim 鎴栬?kruskal 綆楁硶姹傝В, 鎴戞槸鐢ㄧ殑kruskal綆楁硶.

鎸夎竟鐨勫煎仛闈為檷搴忔帓鍒? 鐒跺悗浠庡皬鍒板ぇ瀵規(guī)瘡鏉¤竟涓嬈″垽鏂? 濡傛灉2涓《鐐規(guī)湭鍏ㄩ儴璁塊棶鎴栬呬笉鍦ㄥ悓涓涓泦鍚?閭d箞鍔犱笂榪欐潯杈?鐩村埌鏈鍚庝竴鏉¤竟.
榪欓亾棰樼洰涓嶇敤鍒ゆ柇鍥劇殑鑱旈氭?  鐩存帴杈撳嚭鏈鍚庡凡閫夊垯鐨勮竟鐨勬誨拰鍗沖彲.

浠g爜濡備笅:
MiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?______________鐧界櫧銇眿

#include 
<iostream>
#include 
<algorithm>
using namespace std;
typedef 
struct {
     
int parent;
     
int height;   
}Tset;  

typedef 
struct treeUFS{
       
public:
              treeUFS(
int n = 0):N(n+1) { set = new Tset[N];
                                          visited 
= new bool[N]; 
                                          
for ( int i = 0; i != N; ++ i) 
                                          
set[i].parent = i,set[i].height = 1,visited[i] = false
                                        }
              
~treeUFS(){ delete [] set; };
              
int find ( int x ){  int r = x;  while ( r != set[r].parent ) r = set[r].parent;
                                   
return r;
                                }
              
void setVisit ( int x, int y ) { visited[x] = visited[y] = true; } 
              
bool getVisit ( int x ) { return visited[x]; }
              
void Merge( int x,int y ){  x = find ( x );  y = find ( y );  
                                           
if ( x == y ) return;
                                           
if ( set[x].height == set[y].height ){
                                                
set[y].parent = x;
                                                
set[x].height ++;
                                           }
                                           
else if ( set[x].height < set[y].height ) {
                                                     
set[x].parent = y;       
                                                   }
                                           
else{   set[y].parent = x;
                                               }
                                        }
       
private:
              Tset 
*set;
              
bool *visited;
              
int N;         
}treeUFS; 
typedef 
struct edge {
       
int v1,v2;
       
int wei;     
}EDGE;
EDGE edge[
5005];
bool cmp ( EDGE A, EDGE B )
{
     
return A.wei < B.wei; 
}
int main ()
{
    
int N;
    
while ( scanf ( "%d",&N ) , N )
    {
            
int n = N * ( N - 1 ) / 2;     
            
int v1,v2;
            memset ( edge, 
0 , sizeof ( edge ) );
            treeUFS UFS ( N ); 
            
for ( int i = 1; i <= n; ++ i ) 
            {
                  scanf ( 
"%d%d"&edge[i].v1,&edge[i].v2 );
                  scanf ( 
"%d"&edge[i].wei );
            } 
            sort ( edge 
+ 1, edge + n + 1, cmp );
            
int sum = 0;
            
for ( int i = 1; i <= n; ++ i )
            {
                  
if ( ( !UFS.getVisit(edge[i].v1) || !UFS.getVisit(edge[i].v2) ) || UFS.find(edge[i].v1) != UFS.find(edge[i].v2) )
                  {
                        UFS.setVisit ( edge[i].v1, edge[i].v2 );
                        UFS.Merge ( edge[i].v1, edge[i].v2 );
                        sum 
+= edge[i].wei;
                  }        
            }
            printf ( 
"%d\n",sum );
    }
    
return 0
}



MiYu 2010-08-10 17:47 鍙戣〃璇勮
]]>
HDOJ HDU 1863 鐣呴氬伐紼?ACM 1863 IN HDU http://m.shnenglu.com/MiYu/archive/2010/08/10/122953.htmlMiYuMiYuTue, 10 Aug 2010 09:22:00 GMThttp://m.shnenglu.com/MiYu/archive/2010/08/10/122953.htmlhttp://m.shnenglu.com/MiYu/comments/122953.htmlhttp://m.shnenglu.com/MiYu/archive/2010/08/10/122953.html#Feedback0http://m.shnenglu.com/MiYu/comments/commentRss/122953.htmlhttp://m.shnenglu.com/MiYu/services/trackbacks/122953.htmlMiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?______________鐧界櫧銇眿

棰樼洰鍦板潃:
         http://acm.hdu.edu.cn/showproblem.php?pid=1863
棰樼洰鎻忚堪:
鐣呴氬伐紼?br>
Time Limit: 
1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 
5783    Accepted Submission(s): 2128


Problem Description
鐪佹斂搴?#8220;鐣呴氬伐紼?#8221;鐨勭洰鏍囨槸浣垮叏鐪佷換浣曚袱涓潙搴勯棿閮藉彲浠ュ疄鐜板叕璺氦閫氾紙浣嗕笉涓瀹氭湁鐩存帴鐨勫叕璺浉榪烇紝鍙鑳介棿鎺ラ氳繃鍏礬鍙揪鍗沖彲錛夈傜粡榪囪皟鏌ヨ瘎浼幫紝寰楀埌鐨勭粺璁¤〃涓垪鍑轟簡鏈夊彲鑳藉緩璁懼叕璺殑鑻ュ共鏉¢亾璺殑鎴愭湰銆傜幇璇蜂綘緙栧啓紼嬪簭錛岃綆楀嚭鍏ㄧ渷鐣呴氶渶瑕佺殑鏈浣庢垚鏈?br> 

Input
嫻嬭瘯杈撳叆鍖呭惈鑻ュ共嫻嬭瘯鐢ㄤ緥銆傛瘡涓祴璇曠敤渚嬬殑絎?琛岀粰鍑鴻瘎浼扮殑閬撹礬鏉℃暟 N銆佹潙搴勬暟鐩甅 ( 
< 100 )錛涢殢鍚庣殑 N 
琛屽搴旀潙搴勯棿閬撹礬鐨勬垚鏈紝姣忚緇欏嚭涓瀵規(guī)鏁存暟錛屽垎鍒槸涓や釜鏉戝簞鐨勭紪鍙鳳紝浠ュ強姝や袱鏉戝簞闂撮亾璺殑鎴愭湰錛堜篃鏄鏁存暟錛夈備負(fù)綆鍗曡搗瑙侊紝鏉戝簞浠?鍒癕緙栧彿銆傚綋N涓?鏃訛紝鍏ㄩ儴杈撳叆緇撴潫錛岀浉搴旂殑緇撴灉涓嶈杈撳嚭銆?br> 

Output
瀵規(guī)瘡涓祴璇曠敤渚嬶紝鍦?琛岄噷杈撳嚭鍏ㄧ渷鐣呴氶渶瑕佺殑鏈浣庢垚鏈傝嫢緇熻鏁版嵁涓嶈凍浠ヤ繚璇佺晠閫氾紝鍒欒緭鍑?#8220;
?”銆?br> 

Sample Input
3 3
1 2 1
1 3 2
2 3 4
1 3
2 3 2
0 100
 

Sample Output
3
?

棰樼洰鍒嗘瀽:
鏈灝忕敓鎴愭爲(wèi)鐨勯棶棰?  --->  鐢?prim 鎴栬?kruskal 綆楁硶姹傝В, 鎴戞槸鐢ㄧ殑kruskal綆楁硶.

鎸夎竟鐨勫煎仛闈為檷搴忔帓鍒? 鐒跺悗浠庡皬鍒板ぇ瀵規(guī)瘡鏉¤竟涓嬈″垽鏂? 濡傛灉2涓《鐐規(guī)湭鍏ㄩ儴璁塊棶鎴栬呬笉鍦ㄥ悓涓涓泦鍚?閭d箞鍔犱笂榪欐潯杈?鐩村埌鏈鍚庝竴鏉¤竟.
鏈鍚庡垽鏂竴涓嬪浘鐨勮繛閫氭?濡傛灉涓嶆槸榪為氱殑, 杈撳嚭 ? , 鍚﹀垯杈撳嚭宸查夊垯鐨勮竟鐨勬誨拰.

鍋氳繖涓鐨勬椂鍊橶A浜?嬈?  涓鐩存壘涓嶅埌鍘熷洜, 娌″姙娉曠殑鎯呭喌涓?鍙堟妸鏁版嵁緇撴瀯鐨勪功緲誨嚭鏉?鎶?kruskal
綆楁硶澶嶄範(fàn)浜嗕竴閬? 鍐嶆媯鏌ヤ唬鐮? 鍙戠幇闂浜?  綆楁硶鐨勮繃紼嬫槸涓鏉¤竟涓鏉¤竟鐨勫姞鍏ラ泦鍚堝唴, 鎴戝眳鐒禢C
鐨勫湪杈撳叆鐨勬椂鍊欏氨鍏ㄩ儴鍔犲叆闆嗗悎浜? 緇撴瀯瀵艱嚧 kruskal 綆楁硶鐨勬柇璦娌℃湁璧峰埌浣滅敤. YM. 

浠g爜濡備笅:
MiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?______________鐧界櫧銇眿

#include 
<iostream>
#include 
<algorithm>
using namespace std;
typedef 
struct {
     
int parent;
     
int height;   
}Tset;  

typedef 
struct treeUFS{
       
public:
              treeUFS(
int n = 0):N(n+1) { set = new Tset[N];
                                          visited 
= new bool[N]; 
                                          
for ( int i = 0; i != N; ++ i) 
                                          
set[i].parent = i,set[i].height = 1,visited[i] = false
                                        }
              
~treeUFS(){ delete [] set; };
              
int find ( int x ){  int r = x;  while ( r != set[r].parent ) r = set[r].parent;
                                   
return r;
                                }
              
void init () { for ( int i = 0; i != N; ++ i) 
                             
set[i].parent = i,set[i].height = 1,visited[i] = false;  }
              
void setVisit ( int x, int y ) { visited[x] = visited[y] = true; } 
              
bool getVisit ( int x ) { return visited[x]; }
              
void Merge( int x,int y ){  x = find ( x );  y = find ( y );  
                                           
if ( x == y ) return;
                                           
if ( set[x].height == set[y].height ){
                                                
set[y].parent = x;
                                                
set[x].height ++;
                                           }
                                           
else if ( set[x].height < set[y].height ) {
                                                     
set[x].parent = y;       
                                                   }
                                           
else{   set[y].parent = x;
                                               }
                                        }
              
int getTreeCount (){ int nCount = 0for ( int i = 1; i < N; ++ i ){
                                                         
if ( find (i) == i ){
                                                              nCount 
++
                                                         }
                                                   }
                                   
return nCount;
                                 }
       
private:
              Tset 
*set;
              
bool *visited;
              
int N;         
}treeUFS; 
typedef 
struct edge {
       
int v1;
       
int v2;
       
int wei;     
}EDGE;
EDGE edge[
10005];
bool cmp ( EDGE A, EDGE B )
{
     
return A.wei < B.wei; 
}
int main ()
{
    
int N,M;
    
while ( scanf ( "%d%d",&N,&M ) , N )
    {
            
int v1,v2;
            
if ( M == 0 )
            {
                 puts ( 
"?" );
                 
continue;
            }
            memset ( edge, 
0 , sizeof ( edge ) );
            treeUFS UFS ( M ); 
            
for ( int i = 1; i <= N; ++ i ) 
            {
                  scanf ( 
"%d%d"&edge[i].v1,&edge[i].v2 );
                  scanf ( 
"%d"&edge[i].wei );
            } 
            sort ( edge 
+ 1, edge + N + 1, cmp );
            
int sum = 0;
            
for ( int i = 1; i <= N; ++ i )
            {
                  
if ( ( !UFS.getVisit(edge[i].v1) || !UFS.getVisit(edge[i].v2) ) || UFS.find(edge[i].v1) != UFS.find(edge[i].v2) )
                  {
                        UFS.setVisit ( edge[i].v1, edge[i].v2 );
                        UFS.Merge ( edge[i].v1, edge[i].v2 );
                        sum 
+= edge[i].wei;
                  }        
            }
            
int tCount = UFS.getTreeCount();
            
if ( tCount != 1 )
            {
                 puts ( 
"?" );
                 
continue
            }
            printf ( 
"%d\n",sum );
    }
    
return 0
}


MiYu 2010-08-10 17:22 鍙戣〃璇勮
]]>
HDOJ HDU 1272 灝忓笇鐨勮糠瀹?ACM 1272 IN HDU http://m.shnenglu.com/MiYu/archive/2010/08/10/122929.htmlMiYuMiYuTue, 10 Aug 2010 06:11:00 GMThttp://m.shnenglu.com/MiYu/archive/2010/08/10/122929.htmlhttp://m.shnenglu.com/MiYu/comments/122929.htmlhttp://m.shnenglu.com/MiYu/archive/2010/08/10/122929.html#Feedback0http://m.shnenglu.com/MiYu/comments/commentRss/122929.htmlhttp://m.shnenglu.com/MiYu/services/trackbacks/122929.htmlMiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?______________鐧界櫧銇眿

棰樼洰鍦板潃:
         http://acm.hdu.edu.cn/showproblem.php?pid=1272
棰樼洰鎻忚堪:
灝忓笇鐨勮糠瀹?br>
Time Limit: 
2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 
5006    Accepted Submission(s): 1427


Problem Description
涓婃Gardon鐨勮糠瀹煄鍫″皬甯岀帺浜嗗緢涔咃紙瑙丳roblem B錛夛紝鐜板湪濂逛篃鎯寵璁′竴涓糠瀹Gardon鏉ヨ蛋銆備絾鏄ス璁捐榪峰鐨勬濊礬涓嶄竴鏍鳳紝棣栧厛濂硅涓烘墍鏈夌殑閫氶亾閮藉簲璇ユ槸鍙屽悜榪為氱殑錛屽氨鏄濡傛灉鏈変竴涓氶亾榪為氫簡鎴塊棿A鍜孊錛岄偅涔堟棦鍙互閫氳繃瀹冧粠鎴塊棿A璧板埌鎴塊棿B錛屼篃鍙互閫氳繃瀹冧粠鎴塊棿B璧板埌鎴塊棿A錛屼負(fù)浜嗘彁楂橀毦搴︼紝灝忓笇甯屾湜浠繪剰涓や釜鎴塊棿鏈変笖浠呮湁涓鏉¤礬寰勫彲浠ョ浉閫氾紙闄ら潪璧頒簡鍥炲ご璺級銆傚皬甯岀幇鍦ㄦ妸濂圭殑璁捐鍥劇粰浣狅紝璁╀綘甯繖鍒ゆ柇濂圭殑璁捐鍥炬槸鍚︾鍚堝ス鐨勮璁℃濊礬銆傛瘮濡備笅闈㈢殑渚嬪瓙錛屽墠涓や釜鏄鍚堟潯浠剁殑錛屼絾鏄渶鍚庝竴涓嵈鏈変袱縐嶆柟娉曚粠5鍒拌揪8銆?nbsp;

 

Input
杈撳叆鍖呭惈澶氱粍鏁版嵁錛屾瘡緇勬暟鎹槸涓涓互0 0緇撳熬鐨勬暣鏁板鍒楄〃錛岃〃紺轟簡涓鏉¢氶亾榪炴帴鐨勪袱涓埧闂寸殑緙栧彿銆傛埧闂寸殑緙栧彿鑷沖皯涓?錛屼笖涓嶈秴榪?00000銆傛瘡涓ょ粍鏁版嵁涔嬮棿鏈変竴涓┖琛屻?nbsp;
鏁翠釜鏂囦歡浠ヤ袱涓?/span>-1緇撳熬銆?br> 

Output
瀵逛簬杈撳叆鐨勬瘡涓緇勬暟鎹紝杈撳嚭浠呭寘鎷竴琛屻傚鏋滆榪峰絎﹀悎灝忓笇鐨勬濊礬錛岄偅涔堣緭鍑?/span>"Yes"錛屽惁鍒欒緭鍑?/span>"No"銆?br> 

Sample Input
6 8  5 3  5 2  6 4
5 6  0 0

8 1  7 3  6 2  8 9  7 5
7 4  7 8  7 6  0 0

3 8  6 8  6 4
5 3  5 6  5 2  0 0

-1 -1
 

Sample Output
Yes
Yes
No

棰樼洰鍒嗘瀽:
棰樼洰鐨勮姹傛槸鐢熸垚鐨勫浘涓病鏈夌幆, 鑰屼笖淇濊瘉鍥炬槸榪為氬浘.
            鍒ゆ柇寰堢畝鍗?  姣忎竴瀵硅緭鍏ョ殑鏁版嵁閮借浠栦滑榪涜鍒ゆ柇,鐪嬩粬浠槸涓嶆槸鍦ㄤ竴涓泦鍚堥噷闈? 濡傛灉鍦ㄤ竴涓泦鍚堥噷闈? 閭d箞璇存槑榪欎釜鍥捐榪為?
涔熷氨鏄榪欑粍鏁版嵁鏄笉絎﹀悎瑕佹眰鐨?  鍙﹀涓涓渶瑕佹敞鎰忕殑鍒ゆ柇灝辨槸, 褰撴墍鏈夋暟鎹緭鍏ュ畬鎴愪互鍚? 榪樿鍒ゆ柇鍥劇殑榪為氭? 淇濊瘉鏁翠釜鍥炬槸榪?br>閫氱殑, 濡傛灉闆嗗悎鐨勪釜鏁頒笉涓?,閭e氨鏄 榪欎釜鍥炬湁瀛ょ珛鐐?鎴?澶氫釜闆嗗悎, 閭d箞榪欎釜鍥句篃涓嶇鍚堣姹?
鏈鍚庤杈撳叆鏁版嵁鐨勫垽鏂娉ㄦ剰 涓緇勬暟鎹彧鏈?0 0 鐨勬儏鍐?

浠g爜濡備笅:
MiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?______________鐧界櫧銇眿

#include 
<iostream>
using namespace std;
typedef 
struct {
     
int parent;
     
int height;   
}Tset;  
typedef 
class treeUFS{
       
public:
              treeUFS(
int n = 0):N(n+1) { set = new Tset[N];
                                          visited 
= new bool[N]; 
                                          
for ( int i = 0; i != N; ++ i) 
                                          
set[i].parent = i,set[i].height = 1,visited[i] = false
                                        }
              
~treeUFS(){ delete [] set; };
              
int find ( int x ){  int r = x;  while ( r != set[r].parent ) r = set[r].parent;
                                   
return r;
                                }
              
void init () { for ( int i = 0; i != N; ++ i) 
                             
set[i].parent = i,set[i].height = 1,visited[i] = false;  }
              
void setVisit ( int x, int y ) { visited[x] = visited[y] = true; } 
              
bool getVisit ( int x ) { return visited[x]; }
              
void Merge( int x,int y ){  x = find ( x );  y = find ( y );  
                                           
if ( x == y ) return;
                                           
if ( set[x].height == set[y].height ){
                                                
set[y].parent = x;
                                                
set[x].height ++;
                                           }
                                           
else if ( set[x].height < set[y].height ) {
                                                     
set[x].parent = y;       
                                                   }
                                           
else{
                                                     
set[y].parent = x;
                                               }
                                        }
       
private:
              Tset 
*set;
              
bool *visited;
              
int N;         
}treeUFS;  
int main ()
{
    
int N,M;
    treeUFS UFS ( 
100000 );
    
while ( scanf ( "%d%d"&N, &M ) , N != -1 && M != -1 )
    {
            
if ( M + N == 0 )
            {
                 printf ( 
"Yes\n" ); 
                 
continue;
            }
            
bool fail = false;
            UFS.init ();
            UFS.setVisit ( N,M );
            
if ( UFS.find ( N ) == UFS.find ( M ) )
            {
                 fail 
= true
            }
            UFS.Merge ( N, M );
            
while ( scanf ( "%d%d"&N, &M ) , N + M )
            {
                 UFS.setVisit ( N,M ); 
                 
if ( UFS.find ( N ) == UFS.find ( M ) )
                 {
                      fail 
= true
                 }
                 UFS.Merge ( N, M );   
            }
            
int nCount = 0;
            
for ( int i = 1; i != 100001++ i )
            {
                  
if ( UFS.getVisit (i) && UFS.find(i) == i )
                  {
                       nCount 
++
                       
if ( nCount > 1 )
                       {
                            
break
                       } 
                  } 
            }
            puts ( nCount 
== 1 && !fail ? "Yes" : "No" );
    }
    
return 0;

 


MiYu 2010-08-10 14:11 鍙戣〃璇勮
]]>
鑷繁鐨?騫舵煡闆?妯℃澘http://m.shnenglu.com/MiYu/archive/2010/08/10/122913.htmlMiYuMiYuTue, 10 Aug 2010 03:36:00 GMThttp://m.shnenglu.com/MiYu/archive/2010/08/10/122913.htmlhttp://m.shnenglu.com/MiYu/comments/122913.htmlhttp://m.shnenglu.com/MiYu/archive/2010/08/10/122913.html#Feedback0http://m.shnenglu.com/MiYu/comments/commentRss/122913.htmlhttp://m.shnenglu.com/MiYu/services/trackbacks/122913.htmlMiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?______________鐧界櫧銇眿

鍒氬垰瀛︿範(fàn)瀹屽茍鏌ラ泦鐨勫熀紜鐭ヨ瘑.. 鑷繁鍐欎簡3涓ā鏉跨被 . 鍙戜笂鍜屽ぇ瀹跺垎浜笅:

MiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?______________鐧界櫧銇眿

#include 
<iostream>
using namespace std;
typedef 
class arrUFS{
       
public:
              arrUFS(
int n = 0):N(n){ set = new int[n]; for ( int i = 0; i != N; ++ i) set[i] = i; };
              
~arrUFS(){ delete [] set; };
              
int find ( int x ){ return set[x]; }
              
void Merge1( int a,int b){   int i = min(set[a],set[b]);
                                           
int j = max(set[a],set[b]);
                                           
for ( int k=1; k<=N; k++) {
                                                 
if (set[k] == j)
                                                 
set[k] = i;
                                           }
                                       }
       
private:
              
int *set;
              
int N;         
}arrUFS; 
// 鏁扮粍褰㈠紡

//鏍?wèi)迮烌q舵煡闆? 璺緞鍘嬬緝 
typedef struct {
     
int parent;
     
int cnt;   
}Tset;  

typedef 
class treeUFS{
       
public:
              treeUFS(
int n = 0):N(n+2) { set = new Tset[N]; 
                                          
for ( int i = 0; i != N; ++ i) 
                                          
set[i].parent = i,set[i].cnt = 1
                                        }
              
~treeUFS(){ delete [] set; };
              
int find ( int x ){ int r = x; while ( set[r].parent != r ) //寰幆緇撴潫錛屽垯鎵懼埌鏍硅妭鐐?/span>
                                                    r = set[r],parent;       
                                             
int i = x;
                                             
while ( i != r) //鏈驚鐜慨鏀規(guī)煡鎵捐礬寰勪腑鎵鏈夎妭鐐?/span>
                                             {   
                                                 
int j = set[i].parent;
                                                 
set[i].parent = r;
                                                 i 
= j;
                                             } 
                                   
return r;
                                }
              
void Merge1( int x,int y ){  x = find ( x );  y = find ( y );  
                                           
if ( x == y ) return;
                                           
if ( set[x].cnt > set[y].cnt ){
                                                
set[y].parent = x;
                                                
set[x].cnt += set[y].cnt;
                                           }
                                           
else{
                                                   
set[x].parent = y;
                                                   
set[y].cnt += set[x].cnt;        
                                               }
                                        }
       
private:
              
int *set;
              
int N;         
}treeUFS; 
// 鏍?wèi)迮炲?nbsp; 璺緞鍘嬬緝 

//灞炴у茍鏌ラ泦, 甯︽爲(wèi)娣?nbsp;
typedef struct {
     
int parent;
     
int height;   
}Tset;  

typedef 
class treeUFS{
       
public:
              treeUFS(
int n = 0):N(n+2) { set = new Tset[N];
                                          visited 
= new bool[N]; 
                                          
for ( int i = 0; i != N; ++ i) 
                                          
set[i].parent = i,set[i].height = 1,visited[i] = false
                                        }
              
~treeUFS(){ delete [] set; };
              
int find ( int x ){  int r = x;  while ( r != set[r].parent ) r = ser[r].parent;
                                   
return r;
                                }
              
void Merge1( int x,int y ){  x = find ( x );  y = find ( y );  
                                           
if ( x == y ) return;
                                           
if ( set[x].height == set[y].height ){
                                                
set[y].parent = x;
                                                
set[x].height ++;
                                           }
                                           
else if ( set[x].height < set[y].height ) {
                                                     
set[x].parent = y;       
                                                   }
                                           
else{
                                                     
set[y].parent = x;
                                               }
                                        }
       
private:
              
int *set;
              
bool *visited;
              
int N;         
}treeUFS; 
// 鏍?wèi)迮炲?nbsp;甯︽爲(wèi)娣?nbsp;

int main ()
{
    
return 0
}


MiYu 2010-08-10 11:36 鍙戣〃璇勮
]]>
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            久久久久久久久久久久久久一区 | 久久一二三四| 亚洲一区二区黄| 亚洲一区国产| 久久国产精品一区二区三区| 久久午夜精品一区二区| 免费不卡视频| 欧美天堂亚洲电影院在线播放| 欧美三级电影精品| 国产免费一区二区三区香蕉精| 国产日韩欧美亚洲| 亚洲国语精品自产拍在线观看| 99国内精品久久| 欧美在线免费| 亚洲激情综合| 一区二区欧美亚洲| 久久福利精品| 欧美日韩在线不卡一区| 国产婷婷97碰碰久久人人蜜臀| 在线观看三级视频欧美| 亚洲夜间福利| 蜜臀av性久久久久蜜臀aⅴ四虎| 亚洲国产精品精华液网站| 在线一区二区三区做爰视频网站| 国产亚洲欧美一区| 亚洲制服少妇| 欧美影院在线| 99re国产精品| 欧美日韩精品一本二本三本| 国产精品国产三级欧美二区 | 免费成人高清在线视频| 99国产精品久久久久久久久久| 欧美影视一区| 欧美日韩欧美一区二区| 影院欧美亚洲| 久久精品道一区二区三区| 91久久久久久久久| 久久成人人人人精品欧| 欧美日韩免费看| 最新国产精品拍自在线播放| 久久手机免费观看| 在线亚洲一区| 欧美视频一区二| 一本久久综合亚洲鲁鲁五月天| 鲁鲁狠狠狠7777一区二区| 亚洲午夜三级在线| 欧美午夜一区二区三区免费大片| 一区二区视频免费在线观看| 亚洲欧美视频在线| 亚洲精品一区二区三区婷婷月 | 夜夜爽av福利精品导航| 欧美成人免费全部| 亚洲电影中文字幕| 蜜桃久久精品一区二区| 久久成人18免费观看| 国产日韩一区二区三区在线播放| 亚洲在线一区二区| 亚洲视频免费在线观看| 欧美性色aⅴ视频一区日韩精品| 亚洲伦理精品| 亚洲精品一区二区三区av| 欧美国产在线观看| av成人手机在线| 日韩一级在线| 国产精品第一区| 午夜一级久久| 午夜精品视频网站| 狠狠久久五月精品中文字幕| 另类春色校园亚洲| 免费不卡在线观看av| 亚洲精品日韩激情在线电影| 亚洲人线精品午夜| 国产精品va在线| 欧美在线一二三四区| 欧美中文字幕视频在线观看| 亚洲摸下面视频| 国产精品99久久久久久久女警| 亚洲精品少妇网址| 国产精品激情电影| 久久一区精品| 欧美日本精品| 欧美中文字幕在线播放| 久久人91精品久久久久久不卡| 91久久极品少妇xxxxⅹ软件| 亚洲精一区二区三区| 国产伦精品一区二区三区四区免费| 久久精品国产69国产精品亚洲| 久久婷婷国产综合尤物精品| 99精品国产在热久久下载| 亚洲综合首页| 亚洲精品欧美日韩专区| 亚洲欧美一区二区视频| 亚洲黄色大片| 亚洲影视中文字幕| 亚洲国产黄色| 亚洲欧美日韩高清| 亚洲人成网站精品片在线观看| 亚洲一区二区高清视频| 亚洲欧洲一区二区三区在线观看 | 久久精品1区| 欧美电影在线观看| 久久精品二区三区| 欧美日韩天堂| 欧美成年人视频网站欧美| 欧美丝袜第一区| 欧美福利一区二区三区| 国产精品视频区| 亚洲人成网站影音先锋播放| 国产综合色产| 亚洲欧美大片| 亚洲一区精品电影| 欧美成人资源| 免费看av成人| 国产亚洲欧美日韩一区二区| 中文在线资源观看网站视频免费不卡 | 一区二区三区 在线观看视频| 红桃视频国产精品| 亚洲深夜福利| 99精品欧美| 欧美xxx在线观看| 美女黄毛**国产精品啪啪| 国产欧美日韩免费| 亚洲午夜电影在线观看| 99精品99久久久久久宅男| 快she精品国产999| 可以免费看不卡的av网站| 国产视频亚洲精品| 午夜电影亚洲| 欧美在线观看一二区| 国产精品乱码妇女bbbb| 日韩西西人体444www| 亚洲免费观看高清完整版在线观看| 久久久久久91香蕉国产| 久久久久久黄| 欧美日韩综合在线免费观看| 亚洲精品一区二区三区樱花 | 中日韩美女免费视频网址在线观看| 久久久久久久成人| 久久综合给合| 亚洲国产片色| 欧美精品三级在线观看| 亚洲人久久久| 午夜精品久久久久久久99樱桃| 国产精品欧美精品| 亚洲欧美视频在线| 久久久久se| 亚洲欧洲精品一区二区| 欧美久久综合| 亚洲图片欧美日产| 久久九九精品| 亚洲人体1000| 欧美视频一区在线| 午夜国产不卡在线观看视频| 久久黄色影院| 亚洲精品系列| 欧美亚洲成人网| 亚洲欧美日韩天堂一区二区| 久久亚洲不卡| 亚洲精品一区二区网址| 欧美日韩一区在线播放| 午夜精品电影| 欧美国产日韩视频| 亚洲免费网站| 精品二区久久| 欧美日韩综合另类| 久久久久欧美| 一区二区91| 欧美1区2区视频| 亚洲欧美另类国产| 亚洲高清视频一区| 国产精品久久久久久久久婷婷 | 在线国产精品播放| 欧美精品一区二区蜜臀亚洲| 亚洲一区二区三区视频播放| 麻豆成人综合网| 99视频精品在线| 国产资源精品在线观看| 欧美另类一区| 久久在线播放| 亚洲一区二区在线免费观看| 亚洲大胆女人| 久久久亚洲高清| 亚洲综合第一| 99国产精品久久久久久久| 国产欧美视频一区二区三区| 欧美精品久久一区二区| 久久精品女人| 亚洲在线国产日韩欧美| 亚洲日本欧美| 免费成人高清在线视频| 久久精品视频亚洲| 午夜精品999| 亚洲手机视频| 一区二区三区精密机械公司| 在线观看日产精品| 国内精品嫩模av私拍在线观看 | 国产午夜精品理论片a级探花| 欧美精品一区三区在线观看| 久久综合九色综合欧美就去吻| 欧美中日韩免费视频|