Pagini recente » Cod sursa (job #2640894) | Cod sursa (job #2483611) | Cod sursa (job #1593266) | Cod sursa (job #687799) | Cod sursa (job #1622439)
program disj;
var f,g:text;
n,i,x,y,z,m,j:longint;
marcaj:array of longint;
bufin,bufout:array [1..1 shl 17] of char;
begin
assign(f,'disjoint.in');reset(f);
assign(g,'disjoint.out');rewrite(g);
settextbuf(f,bufin);settextbuf(g,bufout);
readln(f,n,m);
setlength(marcaj,n+1);
for i:=1 to n do
marcaj[i]:=i;
for i:=1 to m do
begin
readln(f,x,y,z);
if x=1 then
begin
for j:=1 to n do
if marcaj[j]=marcaj[z] then
marcaj[j]:=marcaj[y];
end
else
if marcaj[y]=marcaj[z] then
writeln(g,'DA')
else
writeln(g,'NU');
end;
close(f);
close(g);
end.