标签:
for(i=0; i<m; i++)
{
int x,y,son1,son2;
scanf("%d %d",&x,&y);
son1=x;
son2=y;
while(a[x]!=x)
x=a[x];
while(a[y]!=y)
y=a[y];
while(son1!=x)
{
int t;
t=a[son1];
a[son1]=x;
son1=t;
}
while(son2!=y)
{
int t;
t=a[son2];
a[son2]=y;
son2=t;
}
a[y]=x;
}
标签:
原文地址:http://www.cnblogs.com/woyaocheng/p/4966583.html