Pagini recente » Cod sursa (job #1354391) | Cod sursa (job #329500) | Cod sursa (job #430539) | Cod sursa (job #895734) | Cod sursa (job #562404)
Cod sursa(job #562404)
var a,b:array[0..2000000] of char;
c:array[1..1000]of longint;
d:array[1..1000000] of longint;
i,j,n1,n2,nr,poz:longint;
f,g:text;
ok:boolean;
begin
assign(f,'strmatch.in');
assign(g,'strmatch.out');
reset(f);
rewrite(g);
i:=0;
while not eoln(f) do
begin
inc(i);
read(f,a[i]);
end;
n1:=i;
i:=0;
readln(f);
poz:=0;
while not eoln(f) do
begin
inc(i);
read(f,b[i]);
if i>2 then
if (b[i-2]=a[1])and(b[i-1]=a[2])and(b[i]=a[3]) then
begin
inc(poz);
d[poz]:=i-2;
end;
end;
n2:=i;
nr:=0;
// for i:=1 to n2-n1+1 do
for i:=1 to poz do
begin
if d[i]>n2-n1+1 then break;
ok:=true;
for j:=1 to n1 do
if b[d[i]+j-1]<>a[j] then begin ok:=false; break; end;
if ok then
begin
inc(nr);
if nr<=1000 then c[nr]:=d[i]-1;
end;
end;
writeln(g,nr);
if nr>1000 then
for i:=1 to 1000 do
write(g,c[i],' ')
else
for i:=1 to nr do
write(g,c[i],' ');
close(g);
end.