Pagini recente » Cod sursa (job #3281312) | Cod sursa (job #3130972) | Cod sursa (job #745830) | Cod sursa (job #1093083) | Cod sursa (job #12061)
Cod sursa(job #12061)
{q-,r-,s-,d-,i-}
const maxn=(1 shl 20);zero=ord('0');modu=1666013;
{const maxn=(1 shl 10)+6;zero=ord('0');modu=666;}
var t:Text;
V:Array[0..maxn]of longword;
Hash,F,A:array[0..maxn]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 N do begin F[i]:=V[i]-(V[i]div modu)*modu;inc(count[F[i]]);end;
for i:=1 to modu do begin inc(count[i],count[i-1]);From[i]:=count[i]+1;end;
for i:=1 to N do
begin
unde:=F[i];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.