Pagini recente » Cod sursa (job #820531) | Cod sursa (job #131914) | Cod sursa (job #1297854) | Cod sursa (job #2726544) | Cod sursa (job #12063)
Cod sursa(job #12063)
{q-,r-,s-,d-,i-}
const maxn=(1 shl 20);zero=ord('0');modu=666013;
{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;
Hash:array[0..modu*15]of longint;
Count,From:array[0..modu]of longint;
cat,la,lb,lg,unde,i,n,j:longint;s:string;gasit:boolean;
sol:int64;
Procedure get(limit:longint);
begin
fillchar(f,sizeof(f),0);lg:=0;j:=1;cat:=0;
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);
{ writeln((T2-t1)/18.2:0:6); }
for i:=1 to modu do begin Count[i]:=count[i-1]+15;From[i]:=count[i]+1;end;
for i:=1 to N do
begin
unde:=V[i]-(V[i] div modu)*modu;gasit:=false;
for j:=From[unde] to Count[unde] do
if V[Hash[j]]=V[i] then begin gasit:=true;break;end;
if gasit then A[i]:=A[Hash[j]] else
begin dec(From[F[i]]);Hash[From[F[i]]]:=i;inc(lg);A[i]:=lg;end;
end;
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.