Cod sursa(job #841874)

Utilizator RusuAlexeiRusu Alexei RusuAlexei Data 25 decembrie 2012 12:23:14
Problema Sortare topologica Scor 0
Compilator fpc Status done
Runda Arhiva educationala Marime 0.42 kb
program sortaretopologica;
  var f,f2:text;
      n,m,i,x,y:longint;
      a:array [1..50000] of byte;
begin
  assign(f,'sortaret.in');
  reset(f);
  assign(f2,'sortaret.out');
  rewrite(f2);
  readln(f,n,m);
  for i:=1 to m do
    begin
      readln(f,x,y);
      if a[x]=0 then begin write(f2,x,' ');a[x]:=1;end;
      if a[y]=0 then begin write(f2,y,' ');a[y]:=1;end;
    end;
  close(f);
  close(f2);
end.