• Welcome to the world's largest Chinese hacker forum

    Welcome to the world's largest Chinese hacker forum, our forum registration is open! You can now register for technical communication with us, this is a free and open to the world of the BBS, we founded the purpose for the study of network security, please don't release business of black/grey, or on the BBS posts, to seek help hacker if violations, we will permanently frozen your IP and account, thank you for your cooperation. Hacker attack and defense cracking or network Security

    business please click here: Creation Security  From CNHACKTEAM

Recommended Posts




const int N=1e5 10

int p[N];

int find(int x)


if (p[x]!=x)p[x]=find(p[x]);

return p[x];


int main()


int n,m;

CIN nm;

for(int I=1;I=n;I)p=I;

while (m - ) {

char op

int a,b;

cin执行部分a b;

if(op==' M ')p[find(a)]=find(b);


if(find(a)==find(b))puts(' Yes ');

else puts(' No ');





P[ x]用于存储x的父节点号,根节点满足P[x]=x;



Link to comment
Share on other sites