Pagini recente » Cod sursa (job #1746172) | Cod sursa (job #343184) | Cod sursa (job #264711) | Cod sursa (job #1940757) | Cod sursa (job #1622473)
program mire;
var f,g:text;
bufin,bufout:array[1.. 1 shl 16] of byte;
n,m,c,x,y,i:longint;
t:array[1..100000] of longint;
function rad(nod:longint):longint;
begin
if t[nod]<0 then
rad:=nod
else
begin
t[nod]:=rad(t[nod]);
rad:=t[nod];
end
end;
begin
assign(f,'disjoint.in'); reset(f);
assign(g,'disjoint.out'); rewrite(g);
settextbuf(f,bufin); settextbuf(g,bufout);
readln(f,n,m);
for i:=1 to n do
t[i]:=-1;
for i:=1 to m do
begin
readln(f,c,x,y);
if c=1 then
begin
t[y]:=x;
end
else
begin
if rad(x)=rad(y) then
writeln(g,'DA')
ELSE
writeln(g,'NU')
end;
end;
close(f);
close(g);
end.