标签:
Yes
var total,n,m:longint;
father:array[1..10000000]of longint;
used:array[1..10000000]of boolean;
i,j,k,x,y:longint;
yo:boolean;
function find(x:longint):longint;
begin if father[x]=x
then exit(x);
father[x]:=find(father[x]);
exit(father[x]);
end;
procedure union(a,b:longint);
var i,j,k:longint;
begin father[find(a)]:=find(father[b]);
end;
begin yo:=false;
fillchar(father,sizeof(father),0);
fillchar(used,sizeof(used),true);
readln(total,n,m);
for i:=1 to total do
father[i]:=i;
for i:=1 to n do
begin readln(x,y);
if find(x)<>find(y)
then union(x,y);
end;
for i:=1 to m do
begin readln(x,y);
if find(x)=find(y)
then writeln(‘Yes‘)
else writeln(‘No‘);
end;
end.
标签:
原文地址:http://www.cnblogs.com/spiderKK/p/4221915.html