Pagini recente » Cod sursa (job #2649680) | Cod sursa (job #951689) | Cod sursa (job #2858366) | Cod sursa (job #1719010) | Cod sursa (job #228318)
Cod sursa(job #228318)
type point=^longint;
var a:array[1..100000] of point;
f,g:text;
tip,x,y,m,n,i:longint;
begin
assign(f,'disjoint.in'); reset(f);
assign(g,'disjoint.out'); rewrite(g);
read(f,n);
for i:=1 to n do begin
new(a[i]);
a[i]^:=i;
end;
read(f,m);
for i:=1 to m do begin
read(f,tip);
if tip=1 then begin
read(f,x,y);
a[x]:=a[y];
end;
if tip=2 then begin
read(f,x,y);
if a[x]^=a[y]^ then
writeln(g,'DA')
else
writeln(g,'NU');
end;
end;
close(f); close(g);
end.