Cod sursa(job #846584)

Utilizator RusuAlexeiRusu Alexei RusuAlexei Data 2 ianuarie 2013 14:47:37
Problema Parcurgere DFS - componente conexe Scor 10
Compilator fpc Status done
Runda Arhiva educationala Marime 0.37 kb
program dfs;
  var f1,f2:text;
      n,m,i,x,y,k:longint;
      a:array[1..100000] of longint;
begin
  assign(f1,'dfs.in');
  reset(f1);
  assign(f2,'dfs.out');
  rewrite(f2);
  readln(f1,n,m);
  for i:=1 to m do
    begin
      readln(f1,x,y);
      inc(a[y]);
    end;
  for i:=1 to n do if a[i]=0 then inc(k);
  writeln(f2,k);
  close(f1);close(f2);
end.