锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久毛片一区二区,狠狠色丁香久久婷婷综合,久久久久久极精品久久久http://www.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://www.shnenglu.com/MiYu/archive/2010/10/16/130139.htmlMiYuMiYuSat, 16 Oct 2010 08:30:00 GMThttp://www.shnenglu.com/MiYu/archive/2010/10/16/130139.htmlhttp://www.shnenglu.com/MiYu/comments/130139.htmlhttp://www.shnenglu.com/MiYu/archive/2010/10/16/130139.html#Feedback0http://www.shnenglu.com/MiYu/comments/commentRss/130139.htmlhttp://www.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://www.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://www.shnenglu.com/MiYu/archive/2010/08/10/122965.htmlMiYuMiYuTue, 10 Aug 2010 11:23:00 GMThttp://www.shnenglu.com/MiYu/archive/2010/08/10/122965.htmlhttp://www.shnenglu.com/MiYu/comments/122965.htmlhttp://www.shnenglu.com/MiYu/archive/2010/08/10/122965.html#Feedback0http://www.shnenglu.com/MiYu/comments/commentRss/122965.htmlhttp://www.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 琛屽搴旀潙搴勯棿閬撹礬鐨勬垚鏈強淇緩鐘舵侊紝姣忚緇?涓鏁存暟錛屽垎鍒槸涓や釜鏉戝簞鐨勭紪鍙鳳紙浠?緙栧彿鍒癗錛夛紝姝や袱鏉戝簞闂撮亾璺殑鎴愭湰錛屼互鍙婁慨寤虹姸鎬侊細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 <---璇︽儏璇風偣鍑?   
鍑犱箮涓妯′竴鏍? 鍞竴涓嶅悓鐨勬槸: 鍦ㄤ竴浜涙潙搴勪箣闂村凡緇忔湁璺瓨鍦ㄤ簡!!!!
榪欏緢濂藉姙. 鎴戜滑鍙渶瑕佸湪杈撳叆鐨勬椂鍊欐妸宸茬粡瀛樺湪鐨勮礬鎻愬墠鍔犲叆騫舵煡闆嗗氨琛屼簡.
鎺ヤ笅鏉ョ殑灝?鏄?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://www.shnenglu.com/MiYu/archive/2010/08/10/122964.htmlMiYuMiYuTue, 10 Aug 2010 11:11:00 GMThttp://www.shnenglu.com/MiYu/archive/2010/08/10/122964.htmlhttp://www.shnenglu.com/MiYu/comments/122964.htmlhttp://www.shnenglu.com/MiYu/archive/2010/08/10/122964.html#Feedback0http://www.shnenglu.com/MiYu/comments/commentRss/122964.htmlhttp://www.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;鐨勫湴鏂瑰惂錛岀櫨宀涙箹鐨勫眳姘戠敓媧誨湪涓嶅悓鐨勫皬宀涗腑錛屽綋浠栦滑鎯沖幓鍏朵粬鐨勫皬宀涙椂閮借閫氳繃鍒掑皬鑸規潵瀹炵幇銆傜幇鍦ㄦ斂搴滃喅瀹氬ぇ鍔涘彂灞曠櫨宀涙箹錛屽彂灞曢鍏堣瑙e喅鐨勯棶棰樺綋鐒舵槸浜ら氶棶棰橈紝鏀垮簻鍐沖畾瀹炵幇鐧懼矝婀栫殑鍏ㄧ晠閫氾紒緇忚繃鑰冨療灝忕粍RPRush瀵圭櫨宀涙箹鐨勬儏鍐靛厖鍒嗕簡瑙e悗錛屽喅瀹氬湪絎﹀悎鏉′歡鐨勫皬宀涢棿寤轟笂妗ワ紝鎵璋撶鍚堟潯浠訛紝灝辨槸2涓皬宀涗箣闂寸殑璺濈涓嶈兘灝忎簬10綾籌紝涔熶笉鑳藉ぇ浜?000綾熾傚綋鐒訛紝涓轟簡鑺傜渷璧勯噾錛屽彧瑕佹眰瀹炵幇浠繪剰2涓皬宀涗箣闂存湁璺氬嵆鍙傚叾涓ˉ鐨勪環鏍間負 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
!

棰樼洰鍒嗘瀽:
鍥犱負杈規病鏈夌洿鎺ョ粰鍑? 鑰屾槸緇欑殑鍧愭爣鐐? 鎵浠ラ渶瑕佸厛璁$畻 姣忎竴涓偣鍒板叾浠栦換鎰忎竴鐐圭殑璺濈, 騫朵笖璁板綍涓嬫潵.  濡備笅 :
      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++涓婁細鍑虹幇緙栬瘧闂, 鍝ユ偛鍓т簡2嬈?CE   T .T.

灝嗚竟璁板綍濂戒互鍚? 灝辨槸姝e畻鐨?鏈灝忕敓鎴愭爲闂浜?........鐩存帴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://www.shnenglu.com/MiYu/archive/2010/08/10/122956.htmlMiYuMiYuTue, 10 Aug 2010 09:47:00 GMThttp://www.shnenglu.com/MiYu/archive/2010/08/10/122956.htmlhttp://www.shnenglu.com/MiYu/comments/122956.htmlhttp://www.shnenglu.com/MiYu/archive/2010/08/10/122956.html#Feedback0http://www.shnenglu.com/MiYu/comments/commentRss/122956.htmlhttp://www.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;鐨勭洰鏍囨槸浣垮叏鐪佷換浣曚袱涓潙搴勯棿閮藉彲浠ュ疄鐜板叕璺氦閫氾紙浣嗕笉涓瀹氭湁鐩存帴鐨勫叕璺浉榪烇紝鍙鑳介棿鎺ラ氳繃鍏礬鍙揪鍗沖彲錛夛紝騫惰姹傞摵璁劇殑鍏礬鎬婚暱搴︿負鏈灝忋傝璁$畻鏈灝忕殑鍏礬鎬婚暱搴︺?br> 

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

Output
瀵規瘡涓祴璇曠敤渚嬶紝鍦?琛岄噷杈撳嚭鏈灝忕殑鍏礬鎬婚暱搴︺?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

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

鎸夎竟鐨勫煎仛闈為檷搴忔帓鍒? 鐒跺悗浠庡皬鍒板ぇ瀵規瘡鏉¤竟涓嬈″垽鏂? 濡傛灉2涓《鐐規湭鍏ㄩ儴璁塊棶鎴栬呬笉鍦ㄥ悓涓涓泦鍚?閭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://www.shnenglu.com/MiYu/archive/2010/08/10/122953.htmlMiYuMiYuTue, 10 Aug 2010 09:22:00 GMThttp://www.shnenglu.com/MiYu/archive/2010/08/10/122953.htmlhttp://www.shnenglu.com/MiYu/comments/122953.htmlhttp://www.shnenglu.com/MiYu/archive/2010/08/10/122953.html#Feedback0http://www.shnenglu.com/MiYu/comments/commentRss/122953.htmlhttp://www.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 
琛屽搴旀潙搴勯棿閬撹礬鐨勬垚鏈紝姣忚緇欏嚭涓瀵規鏁存暟錛屽垎鍒槸涓や釜鏉戝簞鐨勭紪鍙鳳紝浠ュ強姝や袱鏉戝簞闂撮亾璺殑鎴愭湰錛堜篃鏄鏁存暟錛夈備負綆鍗曡搗瑙侊紝鏉戝簞浠?鍒癕緙栧彿銆傚綋N涓?鏃訛紝鍏ㄩ儴杈撳叆緇撴潫錛岀浉搴旂殑緇撴灉涓嶈杈撳嚭銆?br> 

Output
瀵規瘡涓祴璇曠敤渚嬶紝鍦?琛岄噷杈撳嚭鍏ㄧ渷鐣呴氶渶瑕佺殑鏈浣庢垚鏈傝嫢緇熻鏁版嵁涓嶈凍浠ヤ繚璇佺晠閫氾紝鍒欒緭鍑?#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
?

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

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

鍋氳繖涓鐨勬椂鍊橶A浜?嬈?  涓鐩存壘涓嶅埌鍘熷洜, 娌″姙娉曠殑鎯呭喌涓?鍙堟妸鏁版嵁緇撴瀯鐨勪功緲誨嚭鏉?鎶?kruskal
綆楁硶澶嶄範浜嗕竴閬? 鍐嶆媯鏌ヤ唬鐮? 鍙戠幇闂浜?  綆楁硶鐨勮繃紼嬫槸涓鏉¤竟涓鏉¤竟鐨勫姞鍏ラ泦鍚堝唴, 鎴戝眳鐒禢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://www.shnenglu.com/MiYu/archive/2010/08/10/122929.htmlMiYuMiYuTue, 10 Aug 2010 06:11:00 GMThttp://www.shnenglu.com/MiYu/archive/2010/08/10/122929.htmlhttp://www.shnenglu.com/MiYu/comments/122929.htmlhttp://www.shnenglu.com/MiYu/archive/2010/08/10/122929.html#Feedback0http://www.shnenglu.com/MiYu/comments/commentRss/122929.htmlhttp://www.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錛屼負浜嗘彁楂橀毦搴︼紝灝忓笇甯屾湜浠繪剰涓や釜鎴塊棿鏈変笖浠呮湁涓鏉¤礬寰勫彲浠ョ浉閫氾紙闄ら潪璧頒簡鍥炲ご璺級銆傚皬甯岀幇鍦ㄦ妸濂圭殑璁捐鍥劇粰浣狅紝璁╀綘甯繖鍒ゆ柇濂圭殑璁捐鍥炬槸鍚︾鍚堝ス鐨勮璁℃濊礬銆傛瘮濡備笅闈㈢殑渚嬪瓙錛屽墠涓や釜鏄鍚堟潯浠剁殑錛屼絾鏄渶鍚庝竴涓嵈鏈変袱縐嶆柟娉曚粠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://www.shnenglu.com/MiYu/archive/2010/08/10/122913.htmlMiYuMiYuTue, 10 Aug 2010 03:36:00 GMThttp://www.shnenglu.com/MiYu/archive/2010/08/10/122913.htmlhttp://www.shnenglu.com/MiYu/comments/122913.htmlhttp://www.shnenglu.com/MiYu/archive/2010/08/10/122913.html#Feedback0http://www.shnenglu.com/MiYu/comments/commentRss/122913.htmlhttp://www.shnenglu.com/MiYu/services/trackbacks/122913.htmlMiYu鍘熷垱, 杞笘璇鋒敞鏄?: 杞澆鑷?______________鐧界櫧銇眿

鍒氬垰瀛︿範瀹屽茍鏌ラ泦鐨勫熀紜鐭ヨ瘑.. 鑷繁鍐欎簡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; 
// 鏁扮粍褰㈠紡

//鏍戝艦騫舵煡闆? 璺緞鍘嬬緝 
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) //鏈驚鐜慨鏀規煡鎵捐礬寰勪腑鎵鏈夎妭鐐?/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; 
// 鏍戝艦寮?nbsp; 璺緞鍘嬬緝 

//灞炴у茍鏌ラ泦, 甯︽爲娣?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; 
// 鏍戝艦寮?nbsp;甯︽爲娣?nbsp;

int main ()
{
    
return 0
}


MiYu 2010-08-10 11:36 鍙戣〃璇勮
]]>
国产成人无码精品久久久性色 | 久久精品国产亚洲AV无码娇色| 久久99精品九九九久久婷婷| 国产精品99久久久久久董美香| 国产国产成人精品久久| 国产综合久久久久| 精品久久久久久久久久中文字幕| 久久午夜伦鲁片免费无码| 亚洲精品国产第一综合99久久| 99久久精品毛片免费播放| 97久久精品午夜一区二区| 噜噜噜色噜噜噜久久| 影音先锋女人AV鲁色资源网久久| 久久综合色之久久综合| 久久精品免费一区二区| 国产69精品久久久久9999APGF | 久久久久人妻精品一区| 久久久久99这里有精品10| 久久露脸国产精品| 久久精品国产亚洲av瑜伽| 久久精品视频网| 91久久九九无码成人网站| 国产精品丝袜久久久久久不卡| 狠狠色综合网站久久久久久久高清| 嫩草影院久久99| 国内精品久久久久久中文字幕| 国产精品久久久久久久久鸭| 亚洲精品乱码久久久久久蜜桃图片| 久久99精品国产99久久| 亚洲女久久久噜噜噜熟女| 精品无码久久久久国产| 婷婷五月深深久久精品| 国产精品久久99| 99久久99久久精品国产片果冻| 久久久久久久国产免费看| 99热热久久这里只有精品68| 久久国产亚洲精品| 久久久精品人妻一区二区三区蜜桃| 青青草原1769久久免费播放| 国产亚州精品女人久久久久久 | 亚洲中文字幕久久精品无码喷水|