Pagini recente » Cod sursa (job #2974542) | Cod sursa (job #2797269) | Cod sursa (job #4274) | Cod sursa (job #357177) | Cod sursa (job #1622254)
program paduri;
var f,g:text;
xx:array[1..100000] of longint;
n,m,i,k,cod,x,y,r:longint;
begin
assign(f,'disjoint.in');
assign(g,'disjoint.out');
reset(f);
rewrite(g);
readln(f,n,m);
for i:=1 to n do
xx[i]:=i;
for k:=1 to m do
begin
readln(f,cod,x,y);
r:=xx[y];
if cod=1 then
begin
for i:=1 to n do
if (xx[i]=r) then
xx[i]:=xx[x];
end
else
begin
if xx[x]=xx[y] then
writeln(g,'DA')
else
writeln(g,'NU');
end;
end;
close(f);
close(g);
end.