Pagini recente » Cod sursa (job #2514538) | Cod sursa (job #1182188) | Cod sursa (job #817755) | Cod sursa (job #1297382) | Cod sursa (job #100625)
Cod sursa(job #100625)
var nr,ls,p:integer;
c:array[1..10000000]of byte;
s:array[1..21,1..50000]of byte;
f,g:text;
i,li,n,j,b:longint;
y:string;
ok:boolean;
a:CHAR;
begin
assign(f,'abc2.in');
assign(g,'abc2.out');
reset(f);
rewrite(g);
begin {citire text}
li:=1;
while not(eoln(f))do begin
read(f,a);
if a='a' then c[li]:=1
else if a='b' then c[li]:=2
else c[li]:=3;
inc(li);
end;
end;
begin {citire cuvinte}
n:=li;
li:=1;
readln(f);
readln(f,y);
ls:=length(y);
while not(eof(f))do begin
ok:=true;
{ for i:=1 to li-1 do
if y=s[li,i] then begin ok:=false; break;end;}
if ok= true then begin
p:=0;
for j:=1 to ls do begin
if y[j]='a' then s[li,j]:=1
else if y[j]='b' then s[li,j]:=2
else s[li,j]:=3;
p:=s[li,j]+p;
end;
s[li,ls+1]:=p;
end;
inc(li);
readln(f,y);
end;
end;
ls:=length(y);
begin {partea grea}
for i:=1 to li do begin
for j:=1 to n-ls do begin
if s[i][1]=c[j]then begin
ok:=true;
for b:=2 to ls do begin
if s[i,b]<>c[j+b-1] then begin ok:=false; break; end;
end;
if ok=true then inc(nr);
end;
if ok then break;
end;
end;
end;
writeln(g,nr-1);
close(f);
close(g);
end.