Pagini recente » Cod sursa (job #2390530) | Cod sursa (job #198207) | Cod sursa (job #2317478) | Cod sursa (job #1943342) | Cod sursa (job #550871)
Cod sursa(job #550871)
var i,j,n,m,c,x,y,k:longint;
f1,f2:text;
a:array[1..100000]of longint;
begin
assign(f1,'disjoint.in');
reset(f1);
assign(f2,'disjoint.out');
rewrite(f2);
readln(f1,n,m);
for i:=1 to n do
a[i]:=i;
for i:=1 to m do
begin
readln(f1,c,x,y);
if c=1 then
begin
k:=a[y];
for j:=1 to n do
if a[j]=k then a[j]:=a[x];
end
else
begin
if a[x]=a[y] then writeln(f2,'DA') else writeln(f2,'NU');
end;
end;
close(f1);
close(f2);
end.