Cod sursa(job #10104)

Utilizator bigsarpeadrian bigsarpe Data 27 ianuarie 2007 21:22:43
Problema Secventa 5 Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.1 kb
const maxn=1 shl 20;zero=ord('0');bucata=1 shl 16;modu=bucata-1;
var t:Text;
   V,A,B:array[0..maxn]of longword;s:string;
   by:array[0..maxn]of word;
   Count:array[0..bucata]of longint;
   n,la,lb,i,pas,lg:longint;aux:longword;
   procedure init;
   begin
      assign(T,'secv5.in');reset(T);readln(t,n,la,lb);
      for i:=1 to N do
      begin
         readln(t,S);
         for pas:=1 to length(s) do V[i]:=V[i]*10+ord(S[pas])-zero;
      end;close(t);
   end;
   PRocedure radixsort;
   begin
      for i:=1 to N do begin by[i]:=V[i]and modu;inc(count[by[i]]);end;
      for i:=1 to bucata do inc(count[i],count[i-1]);
      for i:=1 to N do begin B[count[by[i]]]:=i;dec(count[by[i]]);end;
      fillchar(count,sizeof(count),0);
      for i:=1 to N do begin by[i]:=v[i]shr 16;inc(count[by[i]]);end;
      for i:=1 to bucata do inc(count[i],count[i-1]);
      for i:=N downto 1 do begin A[count[By[B[i]]]]:=B[i];dec(count[by[B[i]]]);end;
   end;
{var t1:longint;t2:longint absolute $0:$046c;}
begin
{   t1:=t2;init;writeln((T2-t1)/18.2:0:6);}
   radixsort;
{   writeln((T2-t1)/18.2:0:6);}
end.