锘??xml version="1.0" encoding="utf-8" standalone="yes"?>蜜乳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 緇х畫(huà)鐣呴氬伐紼?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
棰樼洰鎻忚堪:
緇х畫(huà)鐣呴氬伐紼?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;鐨勭洰鏍囨槸浣垮叏鐪佷換浣曚袱涓潙搴勯棿閮藉彲浠ュ疄鐜板叕璺氦閫氾紙浣嗕笉涓瀹氭湁鐩存帴鐨勫叕璺浉榪烇紝鍙鑳介棿鎺ラ氳繃鍏礬鍙揪鍗沖彲錛夈傜幇寰楀埌鍩庨晣閬撹礬緇熻琛紝琛ㄤ腑鍒楀嚭浜?jiǎn)鋼Q鎰忎袱鍩庨晣闂翠慨寤洪亾璺殑璐圭敤錛屼互鍙?qiáng)璇ラ亾璧\鏄惁宸茬粡淇氱殑鐘舵併傜幇璇蜂綘緙栧啓紼嬪簭錛岃綆楀嚭鍏ㄧ渷鐣呴氶渶瑕佺殑鏈浣庢垚鏈?br> 

Input
嫻嬭瘯杈撳叆鍖呭惈鑻ュ共嫻嬭瘯鐢ㄤ緥銆傛瘡涓祴璇曠敤渚嬬殑絎?琛岀粰鍑烘潙搴勬暟鐩甆 ( 
1< N < 100 )錛涢殢鍚庣殑 N(N-1)/2 琛屽搴旀潙搴勯棿閬撹礬鐨勬垚鏈強(qiáng)淇緩鐘舵侊紝姣忚緇?涓鏁存暟錛屽垎鍒槸涓や釜鏉戝簞鐨勭紪鍙鳳紙浠?緙栧彿鍒癗錛夛紝姝や袱鏉戝簞闂撮亾璺殑鎴愭湰錛屼互鍙?qiáng)淇缓鐘舵侊細(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)偣鍑?   
鍑犱箮涓妯′竴鏍? 鍞竴涓嶅悓鐨勬槸: 鍦ㄤ竴浜涙潙搴勪箣闂村凡緇忔湁璺瓨鍦ㄤ簡(jiǎn)!!!!
榪欏緢濂藉姙. 鎴戜滑鍙渶瑕佸湪杈撳叆鐨勬椂鍊欐妸宸茬粡瀛樺湪鐨勮礬鎻愬墠鍔犲叆騫舵煡闆嗗氨琛屼簡(jiǎn).
鎺ヤ笅鏉ョ殑灝?鏄?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瀵圭櫨宀涙箹鐨勬儏鍐靛厖鍒嗕簡(jiǎn)瑙e悗錛屽喅瀹氬湪絎﹀悎鏉′歡鐨勫皬宀涢棿寤轟笂妗ワ紝鎵璋撶鍚堟潯浠訛紝灝辨槸2涓皬宀涗箣闂寸殑璺濈涓嶈兘灝忎簬10綾籌紝涔熶笉鑳藉ぇ浜?000綾熾傚綋鐒?dòng)灱屼皋Z簡(jiǎn)鑺傜渷璧勯噾錛屽彧瑕佹眰瀹炵幇浠繪剰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)插墽浜?jiǎn)2嬈?CE   T .T.

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

Input
嫻嬭瘯杈撳叆鍖呭惈鑻ュ共嫻嬭瘯鐢ㄤ緥銆傛瘡涓祴璇曠敤渚嬬殑絎?琛岀粰鍑烘潙搴勬暟鐩甆 ( 
< 100 )錛涢殢鍚庣殑N(N-1)/2琛屽搴旀潙搴勯棿鐨勮窛紱伙紝姣忚緇欏嚭涓瀵規(guī)鏁存暟錛屽垎鍒槸涓や釜鏉戝簞鐨勭紪鍙鳳紝浠ュ強(qiáng)姝や袱鏉戝簞闂寸殑璺濈銆備負(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;鐨勭洰鏍囨槸浣垮叏鐪佷換浣曚袱涓潙搴勯棿閮藉彲浠ュ疄鐜板叕璺氦閫氾紙浣嗕笉涓瀹氭湁鐩存帴鐨勫叕璺浉榪烇紝鍙鑳介棿鎺ラ氳繃鍏礬鍙揪鍗沖彲錛夈傜粡榪囪皟鏌ヨ瘎浼幫紝寰楀埌鐨勭粺璁¤〃涓垪鍑轟簡(jiǎn)鏈夊彲鑳藉緩璁懼叕璺殑鑻ュ共鏉¢亾璺殑鎴愭湰銆傜幇璇蜂綘緙栧啓紼嬪簭錛岃綆楀嚭鍏ㄧ渷鐣呴氶渶瑕佺殑鏈浣庢垚鏈?br> 

Input
嫻嬭瘯杈撳叆鍖呭惈鑻ュ共嫻嬭瘯鐢ㄤ緥銆傛瘡涓祴璇曠敤渚嬬殑絎?琛岀粰鍑?guó)櫙勪及鐨勯亾璧\鏉℃暟 N銆佹潙搴勬暟鐩甅 ( 
< 100 )錛涢殢鍚庣殑 N 
琛屽搴旀潙搴勯棿閬撹礬鐨勬垚鏈紝姣忚緇欏嚭涓瀵規(guī)鏁存暟錛屽垎鍒槸涓や釜鏉戝簞鐨勭紪鍙鳳紝浠ュ強(qiáng)姝や袱鏉戝簞闂撮亾璺殑鎴愭湰錛堜篃鏄鏁存暟錛夈備負(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)浜?jiǎn)涓閬? 鍐嶆媯(gè)鏌ヤ唬鐮? 鍙戠幇闂?shù)?  綆楁硶鐨勮繃紼嬫槸涓鏉¤竟涓鏉¤竟鐨勫姞鍏ラ泦鍚堝唴, 鎴戝眳鐒禢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鐨勮糠瀹煄鍫″皬甯岀帺浜?jiǎn)寰堜箙锛堣Problem B錛夛紝鐜板湪濂逛篃鎯寵璁′竴涓糠瀹Gardon鏉ヨ蛋銆備絾鏄ス璁捐榪峰鐨勬濊礬涓嶄竴鏍鳳紝棣栧厛濂硅涓烘墍鏈夌殑閫氶亾閮藉簲璇ユ槸鍙屽悜榪為氱殑錛屽氨鏄濡傛灉鏈変竴涓氶亾榪為氫簡(jiǎn)鎴塊棿A鍜孊錛岄偅涔堟棦鍙互閫氳繃瀹冧粠鎴塊棿A璧板埌鎴塊棿B錛屼篃鍙互閫氳繃瀹冧粠鎴塊棿B璧板埌鎴塊棿A錛屼負(fù)浜?jiǎn)鎻愰珮闅惧害锛尀畯甯屽笇鏈涗焕L剰涓や釜鎴塊棿鏈変笖浠呮湁涓鏉¤礬寰勫彲浠ョ浉閫氾紙闄ら潪璧頒簡(jiǎn)鍥炲ご璺級(jí)銆傚皬甯岀幇鍦ㄦ妸濂圭殑璁捐鍥劇粰浣狅紝璁╀綘甯繖鍒ゆ柇濂圭殑璁捐鍥炬槸鍚︾鍚堝ス鐨勮璁℃濊礬銆傛瘮濡備笅闈㈢殑渚嬪瓙錛屽墠涓や釜鏄鍚堟潯浠剁殑錛屼絾鏄渶鍚庝竴涓嵈鏈変袱縐嶆柟娉曚粠5鍒拌揪8銆?nbsp;

 

Input
杈撳叆鍖呭惈澶氱粍鏁版嵁錛屾瘡緇勬暟鎹槸涓涓互0 0緇撳熬鐨勬暣鏁板鍒楄〃錛岃〃紺轟簡(jiǎn)涓鏉¢氶亾榪炴帴鐨勪袱涓埧闂寸殑緙栧彿銆傛埧闂寸殑緙栧彿鑷沖皯涓?錛屼笖涓嶈秴榪?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)瀹屽茍鏌ラ泦鐨勫熀紜鐭ヨ瘑.. 鑷繁鍐欎簡(jiǎ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>
            亚洲国产一区二区a毛片| 久久国产精品久久w女人spa| 亚洲欧美一区二区精品久久久| 欧美在线啊v一区| 欧美成人国产一区二区| 国产精品国产| 韩国久久久久| 亚洲天堂av电影| 美国十次成人| 亚洲天堂av高清| 久久亚洲国产精品一区二区| 欧美日韩中文在线观看| 国产综合网站| 中文在线不卡| 欧美成人黑人xx视频免费观看| 9色国产精品| 快she精品国产999| 国产精品毛片a∨一区二区三区| 在线播放视频一区| 欧美一区二区三区日韩| 最新高清无码专区| 久久精品国产精品亚洲| 欧美色图一区二区三区| 亚洲成人资源| 久久精品国产欧美激情| 日韩视频一区二区三区| 久久人人爽国产| 国产精品视频男人的天堂| 亚洲精品一线二线三线无人区| 久久国产福利| 亚洲天堂网在线观看| 蘑菇福利视频一区播放| 国产伊人精品| 欧美一区二区日韩一区二区| 亚洲日本va在线观看| 久久久一本精品99久久精品66| 国产精品白丝jk黑袜喷水| 最新日韩中文字幕| 久久久国产一区二区| 亚洲午夜电影| 欧美午夜激情视频| 亚洲毛片一区| 欧美成人精品三级在线观看| 欧美亚洲综合另类| 国产精品视频yy9299一区| 一区二区日韩免费看| 欧美激情视频一区二区三区在线播放 | 91久久在线| 久久综合伊人77777尤物| 国产午夜精品理论片a级探花| 亚洲一区区二区| 亚洲国产毛片完整版 | 亚洲片国产一区一级在线观看| 欧美专区在线播放| 亚洲午夜激情免费视频| 欧美日韩亚洲在线| 在线亚洲观看| 亚洲精品乱码久久久久久蜜桃91 | 亚洲人成网站777色婷婷| 免费成人高清| 亚洲激情在线视频| 欧美国产激情| 可以看av的网站久久看| 在线视频国产日韩| 蜜桃av久久久亚洲精品| 久久精品一区二区三区不卡| 国产综合视频| 老巨人导航500精品| 久久精品中文字幕免费mv| 激情综合亚洲| 欧美不卡三区| 欧美xx视频| 亚洲美女一区| 亚洲乱码国产乱码精品精天堂 | 一区二区三区欧美在线观看| 亚洲免费电影在线观看| 欧美亚州在线观看| 亚欧美中日韩视频| 欧美诱惑福利视频| 影音先锋成人资源站| 欧美激情亚洲综合一区| 欧美肥婆在线| 亚洲一区二区免费看| 亚洲欧美高清| 狠狠入ady亚洲精品| 欧美粗暴jizz性欧美20| 欧美黑人在线观看| 亚洲欧美电影在线观看| 欧美诱惑福利视频| 亚洲第一精品福利| 最新国产精品拍自在线播放| 欧美午夜片在线免费观看| 欧美一区网站| 久久一区二区三区四区| 一个色综合av| 亚洲男女自偷自拍图片另类| 国产在线一区二区三区四区| 欧美aa在线视频| 欧美日本中文| 久久成人18免费网站| 美女日韩在线中文字幕| 在线一区亚洲| 性一交一乱一区二区洋洋av| 在线看视频不卡| 日韩视频免费观看高清在线视频| 国产精品美女www爽爽爽视频| 久久综合中文字幕| 欧美激情一区二区三区四区| 亚洲欧美在线一区| 久久综合网hezyo| 亚洲午夜精品福利| 久久九九热re6这里有精品| 亚洲精品日本| 先锋资源久久| 亚洲免费观看在线观看| 亚洲综合不卡| 亚洲另类黄色| 午夜精品国产更新| 99re8这里有精品热视频免费| 亚洲欧美亚洲| 99视频在线观看一区三区| 校园春色国产精品| 日韩系列欧美系列| 久久精品亚洲乱码伦伦中文 | 国产精品久久久久aaaa九色| 久久综合久久综合久久综合| 欧美日韩在线不卡一区| 猛男gaygay欧美视频| 国产精品久久久久国产精品日日| 欧美电影免费观看大全| 国产精品素人视频| 91久久中文| 在线日韩成人| 亚洲欧美日韩成人| 在线亚洲精品| 欧美成人激情视频| 久久久久久久波多野高潮日日| 欧美日韩视频免费播放| 欧美大片专区| 国产一区二区三区不卡在线观看| 日韩一级黄色av| 亚洲欧洲久久| 久久久国际精品| 久久视频这里只有精品| 一本一本a久久| 亚洲精品社区| 亚洲福利视频专区| 亚洲欧美日韩在线不卡| 在线一区亚洲| 欧美激情1区2区3区| 欧美xxx成人| 国语精品中文字幕| 性高湖久久久久久久久| 午夜免费日韩视频| 欧美三级网页| 亚洲精品一区二区三区四区高清| 国模精品一区二区三区| 亚洲你懂的在线视频| 亚洲在线观看免费| 亚洲人成在线播放| 欧美高清免费| 欧美黄在线观看| 精品动漫3d一区二区三区免费| 亚洲在线一区二区三区| 亚洲午夜av在线| 欧美日韩在线精品| 亚洲人成啪啪网站| 99www免费人成精品| 欧美精品18+| 91久久视频| 亚洲免费观看视频| 欧美精品在线一区二区三区| 亚洲国产va精品久久久不卡综合| 在线精品视频一区二区| 久久久国产午夜精品| 暖暖成人免费视频| **性色生活片久久毛片| 免费欧美在线视频| 亚洲第一天堂无码专区| 亚洲人成在线观看一区二区| 久久久久久一区二区| 久久久久久成人| 国产日韩精品在线| 亚洲无线视频| 欧美一区二区三区免费观看| 国产伦精品一区二区三区照片91| 香蕉亚洲视频| 久久免费视频这里只有精品| 在线观看91久久久久久| 男人天堂欧美日韩| 亚洲三级观看| 亚洲男女毛片无遮挡| 国产欧美日韩一区二区三区| 久久精品国产第一区二区三区最新章节 | 亚洲精品一区二区网址| 中文在线不卡视频| 国产精品一区二区你懂的| 久久精品国产第一区二区三区最新章节 | 这里只有精品电影| 欧美一区成人|