1 var 2 father:array[1..10000] of integer; 3 n,i:integer; 4 function getfather(a:integer):integer; 5 begin 6 if father[a]=0 then exit(0); 7 father[a]:=getfather(father[a]); 8 getfather:=father[a]; 9 end;10 function judge_union(a,b:integer):boolean;11 var12 fa,fb:integer;13 begin14 fa:=father[a];15 fb:=father[b];16 if fa=fb then exit(true);17 father[fa]:=fb;18 exit(false);19 end;