Pagini recente » Cod sursa (job #2591045) | Cod sursa (job #1791717) | Cod sursa (job #1449036) | Cod sursa (job #2348842) | Cod sursa (job #1179878)
var t,p,s:ansistring;
n,m,i,l,r,sol:longint;
z,a:array[0..2000000] of longint;
b1,b2:array[1..1 shl 17] of char;
begin
assign(input,'strmatch.in');
reset(input);
assign(output,'strmatch.out');
rewrite(output);
settextbuf(input,b1);
settextbuf(output,b2);
readln(p);
readln(t);
n:=length(p);
m:=length(t);
s:=p+'#'+t;
z[1]:=0;
for i:=2 to n+m+1 do
begin
if i<=r then
if z[i-l+1]<r-i+1 then
z[i]:=z[i-l+1] else z[i]:=r-i+1;
while (i+z[i]<=n+m+1) and (s[z[i]+1]=s[i+z[i]]) do inc(z[i]);
if i+z[i]-1>r then begin l:=i; r:=i+z[i]-1; end;
end;
for i:=1 to m do
if z[i+1+n]=n then
begin
inc(sol);
a[sol]:=i;
end;
writeln(sol);
for i:=1 to sol do begin
write(a[i]-1,' ');
if i=1000 then break;
end;
close(output);
end.