- 家族
- 2009-02-15 10:54:29 @
只得了20分
const
maxn=5000;
var
father:array[1..maxn] of integer;
t,n,m,p,i,x,y,fx,fy:integer;
function get(x:integer):integer;
begin
if father[x]=0 then
exit(x);
father[x]:=get(father[x]);
get:=father[x];
end;
begin
read(n,m,p);
fillchar(father,sizeof(Father),0);
for i:=1 to m do
begin
read(x,y);
fx:=get(x);
fy:=get(y);
if fxfy then
father[y]:=x;
end;
for i:=1 to n do
t:=get(i);
for i:=1 to p do
begin
read(x,y);
fx:=get(x);
fy:=get(y);
if fx=fy then
writeln('Yes')
else
writeln('No');
end;
end.
0 条评论
目前还没有评论...