Pagini recente » Rating tbp8500 (tbp8500) | Cod sursa (job #3160717) | Cod sursa (job #930768) | Cod sursa (job #943039) | Cod sursa (job #10114)
Cod sursa(job #10114)
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;last:longword;
return:int64;
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);}
last:=V[A[1]];lg:=1;
for i:=1 to N do if V[A[i]]=last then
begin last:=v[a[i]];inc(lg);V[A[i]]:=lg;end;
if lg>=1 shl 10 then repeat until false;
assign(t,'secv5.out');rewrite(T);writeln(t,return);close(T);
{ writeln((T2-t1)/18.2:0:6);}
end.