Pagini recente » Cod sursa (job #3267337) | Cod sursa (job #2026251) | Cod sursa (job #1578536) | Cod sursa (job #1432795) | Cod sursa (job #1623321)
program disj;
var f,g:text;
n,i,x,y,z,m,j,semnz,semny: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
semnz:=marcaj[z];
semny:=marcaj[y];
for j:=1 to n do
if marcaj[j]=semnz then
marcaj[j]:=semny;
end
else
if marcaj[y]=marcaj[z] then
writeln(g,'DA')
else
writeln(g,'NU');
end;
close(f);
close(g);
end.