Pagini recente » Cod sursa (job #592506) | Cod sursa (job #2056906) | Cod sursa (job #1888397) | Cod sursa (job #1531346) | Cod sursa (job #291468)
Cod sursa(job #291468)
program suma;
const fin = 'disjoint.in';
fout = 'disjoint.out';
type lp = ^articol;
articol = ^lp;
var m:array [1..100000] of lp;
n,x,y,op,i:longint;
procedure join(x,y:integer);
begin
m[y]^:=m[x]^;
m[y]:=m[y]^^;
end;
procedure query(x,y:integer);
begin
if m[x]^ = m[y]^ then
writeln('DA')
else
writeln('NU');
end;
begin
assign(input,fin);
assign(output,fout);
reset(input);
rewrite(output);
read(n);
for i:=1 to n do
begin
new(m[i]);
new(m[i]^);
m[i]^^:=m[i];
end;
readln(x);
while not eof() do
begin
readln(op,x,y);
if op = 1 then
join(x,y)
else
query(x,y);
end;
close(input);
close(output);
end.