Pagini recente » Cod sursa (job #1929078) | Cod sursa (job #1921253) | Cod sursa (job #2394226) | Istoria paginii runda/blablalblalblalfefefeffe/clasament | Cod sursa (job #1089129)
var i,j,n,m,x,y,k:longint;
u:byte;
a:array[1..1001,1..1001] of byte;
b:array[1..1001] of byte;
procedure conex(c:longint);
begin
b[c]:=1;
for i:=1 to n do
if (b[i]=0) and (a[c][i]=1) then conex(i);
end;
begin
assign(input,'dfs.in');
assign(output,'dfs.out');
reset(input);
rewrite(output);
read(n); readln(m);
for i:=1 to m do
begin
read(x); readln(y);
a[x][y]:=1;
a[y][x]:=1;
end;
for i:=1 to n do
if b[i]=0 then begin
inc(k);
conex(i);
end;
writeln(k);
close(input);
close(output);
{Totusi este trist in lume}
end.