标签:return turn class blog style merge pre div log
并查集:
1 int find(int a) 2 { 3 int r=a; 4 while(f[r]!=r) 5 r=f[r]; 6 int i=a; 7 int j; 8 while(i!=r) 9 { 10 j=f[i]; 11 f[i]=r; 12 i=j; 13 } 14 return r; 15 } 16 int merge(int a,int b) 17 { 18 int A,B; 19 A=find(a); 20 B=find(b); 21 if(A!=B) 22 { 23 f[B]=A; 24 } 25 }
标签:return turn class blog style merge pre div log
原文地址:http://www.cnblogs.com/ECJTUACM-873284962/p/6562229.html