Pagini recente » Cod sursa (job #600050) | Cod sursa (job #1754173) | Cod sursa (job #1879615) | Cod sursa (job #190644) | Cod sursa (job #1622455)
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.