Pagini recente » Cod sursa (job #704501) | Cod sursa (job #621700) | Cod sursa (job #2179610) | Cod sursa (job #2941084) | Cod sursa (job #12094)
Cod sursa(job #12094)
{q-,r-,s-,d-,i-}
const maxn=(1 shl 20);zero=ord('0');modu1=666013;modu2=405617;cat=3;
{const maxn=(1 shl 10)+6;zero=ord('0');modu=666;}
var t:Text;
V:Array[0..maxn]of longword;
A,F:array[0..maxn]of longint;
Hash1:array[0..modu1*cat]of longint;
Hash2:array[0..modu2*cat]of longint;
grad1,from1:array[0..modu1]of longint;
grad2,from2:Array[0..modu2]of longint;
la,lb,lg,unde1,unde2,i,n,j:longint;s:string;gasit:boolean;
sol:int64;
Procedure get(limit:longint);
begin
fillchar(f,sizeof(f),0);lg:=0;j:=1;
for i:=1 to N do
begin
while (lg<=limit)and(j<=N)do
begin if F[A[j]]=0 then inc(lg);inc(f[A[j]]);inc(j);end;
if lg>limit then inc(sol,j-1) else inc(sol,j);
dec(f[a[i]]);if F[A[i]]=0 then dec(lg);
end;
end;
{var t1:longint;t2:longint absolute $0:$046c;}
begin
{ t1:=t2;}
assign(T,'secv5.in');reset(T);readln(t,n,la,lb);
for i:=1 to N do
begin readln(t,S);for j:=1 to length(S) do V[i]:=V[i]*10+ord(s[j])-zero;end;
close(T);V[0]:=-1;
j:=0;for i:=1 to modu1 do begin inc(j,cat);Grad1[i]:=j;end;
j:=0;for i:=1 to modu2 do begin inc(j,cat);Grad2[i]:=j;end;
for i:=1 to N do
begin
unde1:=V[i]-(v[i]div modu1)*modu1;gasit:=false;
for j:=grad1[unde1]downto grad1[unde1]-from1[unde1]+1 do
if V[Hash1[j]]=V[i] then
begin gasit:=true;A[i]:=A[hash1[j]];break;end;
if not gasit then
begin
unde2:=V[i]-(v[i]div modu2)*modu2;gasit:=false;
for j:=grad2[unde2]downto grad2[unde2]-from2[unde2]+1 do
if V[Hash2[j]]=V[i] then
begin gasit:=true;A[i]:=A[hash2[j]];break;end;
if not gasit then
begin
inc(lg);A[i]:=lg;
if From1[unde1]<From2[unde2] then
begin Hash1[grad1[unde1]-from1[unde1]]:=i;inc(From1[unde1]);end else
begin Hash2[grad2[unde2]-from2[unde2]]:=i;inc(From2[unde2]);end;
end;
end;
end;
if lg>=maxN-1000 then repeat writeln;until false;
{ get(lb);sol:=-sol;get(la-1);
assign(t,'secv5.out');rewrite(T);writeln(T,-sol);close(T);
writeln((T2-t1)/18.2:0:6);}
end.