Pagini recente » Cod sursa (job #2595844) | Monitorul de evaluare | Cowfood | Cod sursa (job #3040969) | Cod sursa (job #1179872)
var t,p,s:ansistring;
n,m,i,l,r,sol:longint;
z,a:array[0..2000000] of longint;
begin
assign(input,'strmatch.in');
reset(input);
assign(output,'strmatch.out');
rewrite(output);
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 write(a[i]-1,' ');
close(output);
end.